Yes . Now I included a a while loop that would throw away all the buffered data .
while( getchar() != '\n' ) ;
Here is my new code
Now it isnt Executing unwated scanf's without my knowing but it dosnt End the Loop on EOF .Code:#include <stdio.h> int main( void ) { int Ivar= 0; int Ivar1 ; char ch; printf( "Enter:" ); while ( scanf( "%c" , &Ivar ) != EOF ) { printf ( "ANSI = %d, Char = %c\n", Ivar, Ivar ); printf( "Enter:" ); while ( getchar() != '\n' ) ; } system( "pause" ); return 0; }
Isnt there a compiler that knows how to handle scanf properly and not allow such things to happen ?In reality, scanf() does not handle input as gracefully as it could.