Mail Archives: djgpp/1994/09/01/12:09:05
This is the correct behavior of scanf(); it will work that way on all
C compilers.
The problem with your test program is that when scanf() encounters an
illegal character according to its format specification, it will not
remove it from the input stream, so you are continually trying to scan
the same invalid string. One way of fixing this would be to call
"fflush(stdin)" after when you scanf() has failed, or before every
scanf() call, whichever is more appropriate...
Hope this clears things up,
Peter Jones
- Raw text -