My approach is to take the user input in as a string, while forcing numeric input between 14 and 16 characters long. I think my code should do that, but I get a segmentation fault for numeric inputs with less than 14 or more than 16 characters, or any letters, instead of being reprompted. What's wrong with my code?
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
int main(void)
{
// declare variables
string cardnum = 0;
// Get value from user
do
{
printf("Card Number:");
cardnum = GetString();
}
while ((strlen(cardnum) < 14 || strlen(cardnum) > 16) && isdigit(cardnum) );