On Mon, 26 Jul 1999, Moses Leslie wrote: > On 27-Jul-99 Jason Gunthorpe wrote: > > > > fflush doesn't do anything (or at least isn't supposed to) for input > > streams, fflush is ment to flush pending output, not discard pending > > input. So what is happening is that glibc ignores the fflush and > > continually rescans that invalid character in a loop.
If you check the return value for fflush on stdin, it _should_ be EBADF (according to the manpage). Why am i not surprised the micros~1 C is borken? > Ok, thanks for the quick response. Do you happen to know if there's a similar > way to find out if scanf got a valid input? IIUC, that's what the return value is for. If scanf returns 0, it couldn't match anything. If you pass it 4 variables and it returns 2, then there wasn't a match for the last two in the pattern. If scanf returns EOF, then there was an input failure. man scanf for more info (with the manpages-dev package installed, of course). And finally, one piece of advice not directly related to your problem: learn to use gdb, it can be _extremely_ helpful.

