Å
å´å¹³
int get_int(void)
{
int input;
char ch;
while(scanf("%d",&input)!=1)
{
while((ch=getchar())!='\n')
putchar(ch);
printf(" is not an integer.\nPlease enter an integer value, such as 25,-178 or 3: ");
}
return input;
}
///////////////////////////////////////////////////
Here is the code from C Primer Plus, when the input is not an integer, it print the wrong input.
My question is, if scanf() gets the wrong input, it doesn't through out the wrong input, but give it to next receiver?
Poor English, sorry for that.
{
int input;
char ch;
while(scanf("%d",&input)!=1)
{
while((ch=getchar())!='\n')
putchar(ch);
printf(" is not an integer.\nPlease enter an integer value, such as 25,-178 or 3: ");
}
return input;
}
///////////////////////////////////////////////////
Here is the code from C Primer Plus, when the input is not an integer, it print the wrong input.
My question is, if scanf() gets the wrong input, it doesn't through out the wrong input, but give it to next receiver?
Poor English, sorry for that.