www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/16/04:29:31

Date: Tue, 16 Apr 1996 16:22:17 +0800 (GMT+0800)
From: Old System Diagnostic <sysdiag AT mozcom2 DOT mozcom DOT com>
To: j DOT aldrich6 AT genie DOT com
cc: djgpp AT delorie DOT com
Subject: Re: End of file keyboard symbo
In-Reply-To: <199604160421.AA018178512@relay1.geis.com>
Message-ID: <Pine.SUN.3.91.960416162041.489A-100000@mozcom2.mozcom.com>
MIME-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019