Mail Archives: djgpp/1996/04/16/04:29:31
On Tue, 16 Apr 1996 j DOT aldrich6 AT genie DOT com wrote:
> The idea solution to all of this is to simply use gets() and sscanf().
> If gets() sees an EOF, it simply returns NULL, and no matter what
> else goes on, it gets an entire input line, including the c/r. So if
> the user wants to end input with an EOF, just check the return value
> of gets().
>
> The other really nice thing about using gets() is that it doesn't force
> the user to type anything before pressing Enter. Just examine the
> resulting buffer. If you really expect input, just prompt the user again.
Uh, before you get carried away with your praise of gets (), remember that
gets () was what let the Internet Worm work. It doesn't check for buffer
overflow. I suggest (as do zillions of other people) fgets().
- Raw text -