What's so bad about scanf anyway???
Rob Lemley
rob at b15.INGR.COM
Tue Nov 13 10:49:48 AEST 1990
In <1990Nov12.050450.7194 at Solbourne.COM> imp at marvin.Solbourne.COM (Warner Losh) writes:
>True. However, I'd use fgets(). See below.
. . .
>gets() is a bad function to use when you don't have total control over
>the input (like a user typing at a program). Since it can't check to
>see if the input line is too large for the buffer, "bad things" can
>happen as a result.
Another bad:
Both gets() and fgets() (SysV R3) will blindly read in NULL chars
(ascii zero's). Since gets() and fgets() return no info about the
number of chars read (unless you use ftell() maybe?), you might throw
away a whole or partial line of input (and never know about it!).
Rob
--
Rob Lemley
System Consultant, Scanning Software, Intergraph, Huntsville, AL
rcl at b15.ingr.com OR ...!uunet!ingr!b15!rob
205-730-1546
More information about the Comp.lang.c
mailing list