Substitute for gets()
Barry Margolin
barmar at think.COM
Thu Feb 9 07:11:35 AEST 1989
In article <721 at hscfvax.harvard.edu> xmjschm at hscfvax.harvard.edu (MJSchmelzer) writes:
[Describes problems using scanf() in place of gets().]
>Does this mean gets() is indispensable ?
I don't think so. The simplest, safe replacement for gets() is
fgets(). You'll have to specify stdin explicitly, and you'll have to
strip off the trailing newline if you don't want it, but otherwise
it's just what you want.
Barry Margolin
Thinking Machines Corp.
barmar at think.com
{uunet,harvard}!think!barmar
More information about the Comp.lang.c
mailing list