Hey guys how would i make sure that only an int is being entered and not a char. Im using sscanf() as the function to enter input as an integer.
But the thing is it compiles but when i run it and i press a character such as the letter 'c' the program goes bolistic and goes into an inifinate loop how can i stop this with some validation to make sure that only an int is entered?
Code:fscanf(stdin, "%d", &input); if(isalpha(input)) { printf("you have entered a char please enter an integer"); } else { printf("You have correctly inputed the integer"); }