Keith Thompson said:
Neither gets() nor fgets() solves the problem.
fgets() requires an argument specifying the maximum input length. If
the input line exceeds that length, fgets() returns before reading the
new-line; if stdin is line-buffered, additional characters will be
left on the input stream, waiting to be read by the next input
operation. It also requires a pointer to storage for a sequence of
characters that are going to be discarded anyway.
gets() is inherently dangerous, and should never be used.
I said it before and I'll say it again...sheesh...
Use fgets() with say a 512-byte static buffer you keep in a library just
for crap like this, and specifically instruct the user to press RETURN,
and of course you'll still find something to whine about, but in essence
all you're doing is using the "event loop" of fgets() to break out of the
loop and "continue", which is what the OP wanted to do, which is simple
to do, but for some strange reason is IMPOSSIBLE to do here in the
well-padded confines of this newsgroup...
I mean, this is just a step ahead (or below!) the "hello world" level
of programming, but SHEEEEEEESH...it's beyond the newsgroup
"regulars"...and yes I've said it before, but it is beyond me how anybody
with that kind of attitude could ever manage to write any useful
computer code in their life...