I'm trying to a simple ticketing machine program. I prompt for user input in integer form because my assignment forced to be so. So i write as follow:
Code:
#include <stdio.h>
int main (void)
int departure, destination;
printf("Please enter your destination [0-10]: ");
scanf("%d",destination);
while (destination<0 || destination>10)
{
printf("Error! Please enter appropriate destination.");
printf("Please enter your destination [0-10]: ");
scanf("%d",destination);
}
Yet, problem occured when i testing the program.
If the user enter character as input, then my program will keep on non-stop poping out my "loop part".
It just would be fine when key in integer but it will error when users entering character. So, how m i going to prevent it non-stop poping out error when users entering character ???