another way to clear the buffer
So in my book they gave this example of how to control the garbege from scanf
Code:
ex: while ( (scanf("%d", &input) !=1)
scanf("%*s");
I understand the fact that it skips to the next whitespace in STDIN queque . what I don't understand is how when I try to get the garbege out with
Code:
while ( (ch = getchar())!='\n') printf("%c is not an integer", ch);
nothing seems to come out..
how is it that the buffer seems to be cleared out. I thought the "*" operator only skipped over it. isn't it still in the buffer when it skips over, or does it just ignore the input period and doesn't read anything.