int main()
{
int n;
while(scanf("%d", & n) < 1) {// scanf accepts several parameters, here <; A few
printf("input error. try again ... ");
while(getchar() ! = '\n');
}
printf("%d", n);
}
For example,
scanf ("%d% d",&; a, & b) < 2
scanf returns the number of variables successfully entered, and returns EOF if none of them are successful.