Hi,
Kindly I hope that I can find help regarding reusing of scanf.
If the user should enter only integers not floats and the scanf is within a for loop. how can I force the program to continue normally when EOF happens as a result of wrong input?
Example:
int i , x, n=5;
for(i=0;i<n;i++)
{
if ( (scanf ("%d", &x)==1) )
{
printf("Integar is entered\n");
}
else
{
printf("Please enter an integer\n");
i--;
}
}
the above program just goes into infinite loop, how can I let the program accepts continuous numbers as inputs without interrupting (i.e. let the user to input a correct input istead of the wrong one) ?