Mail Archives: djgpp/1994/09/01/15:13:17
Hi Peter,
You are correct. My test program works the same way under the
different OS's/Compiler. When I include fflush(stdin), only djgpp
gives a problem. Thus the bug(?) isn't in scanf(), but is in
fflush(stdin).
Looking more carefully at the real code that generated the error, I
discovered that I'd been already been running fflush(stdin) after this
block of code exited (the code was initially developed under SUNOS, and
so I probably had to do this to avoid the problem in the first place).
Hence, any remaining input would be flushed (and is, except under
djgpp).
While I had programmed around the problem by using gets()/sscanf() much
like you suggested, in this part of my application, scanf() is really
much simpler. For now the best suggestion I received is to clean up by
using scanf("%*[^\n]\n"), which works.
Thanks to all.
- Raw text -