fscanf & EOF

Karl Heuer karl at ima.isc.com
Tue Feb 12 13:35:17 AEST 1991


In article <1991Feb11.213431.9260 at wpi.WPI.EDU> fenn at wpi.WPI.EDU (Brian Fennell) writes:
>[You can't use scanf("%1s", ch) where ch is just a char; it needs an array of
>at least two characters, since it will try to store the '\0' too.]

Right.  This is a long-standing bug in the man page for scanf(), which claims
that "%1s" is a good substitute for "%c" if you want to force it to skip
initial whitespace.  (The correct substitute is " %c".)

Karl W. Z. Heuer (karl at ima.isc.com or uunet!ima!karl), The Walking Lint



More information about the Comp.lang.c mailing list