例如:
printf("Continue?
>>");
scanf("%d", &cont);
getchar();
Normally I add the getchar() to prevent the program from infinite looping (reading off the character from the buffer). However, when used with a menu following this statement the extra characters are read in and any scanfs following the character input (up to the number of characters input) are skipped.
What I want to figure out is how to prevent it from skipping forward through several sections of my program when it reads in a type of input other than an int. Would this be best solved by putting it inside of a loop that won t continue until the variable is in the expected domain?