I'm trying to ensure that the user has definitely entered an integer. However no matter what I type in, it doesn't seem to work.
Sometimes the scanf is completely ignored and the loop just prints out everything loads of times.
When I checked what the input was that the code took in, it was wrong as well.
Any ideas or help would be appreciated!
while (square_size == -1) {
square_size = get_input_size();
}
int get_input_size(void) {
int size;
printf("What size word square would you like to create? ");
scanf("%d", &size);
if (isdigit(size)) {
printf("VALID %d\n", size);
return size;
}
printf("ERROR: invalid input\n");
return -1;
}