Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!decwrl!deccrl!news.crl.dec.com!decvax.dec.com!ima!dirtydog!karl From: karl@ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: fscanf & EOF Message-ID: <1991Feb12.023517.4294@dirtydog.ima.isc.com> Date: 12 Feb 91 02:35:17 GMT References: <2145@novavax.UUCP> <1991Feb11.213431.9260@wpi.WPI.EDU> Sender: news@dirtydog.ima.isc.com (NEWS ADMIN) Reply-To: karl@ima.isc.com (Karl Heuer) Organization: Interactive Systems Lines: 9 In article <1991Feb11.213431.9260@wpi.WPI.EDU> fenn@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@ima.isc.com or uunet!ima!karl), The Walking Lint