input validation making sure only an int is entered
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?
fscanf(stdin, "%d", &input);
printf("you have entered a char please enter an integer");
printf("You have correctly inputed the integer");