char a;
while(scanf("%c", &a)==1){
}
char a;
while((a = getchar())!=EOF){
}
I thought these two code would do the same thing, but actually it looks like their different. They do work the same usually, but with some specific inputs, it works differently.
When standard input has value FF(255) in it, using EOF would terminate while scanf() will keep going untill the end of the input. Why does it happen and how can I use getchar() and do the same thing as while(scanf())