Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!bbn!oliveb!tymix!tardis!jms From: jms@tardis.Tymnet.COM (Joe Smith) Newsgroups: comp.sys.amiga Subject: Re: C scanf question Summary: use "%*c" to skip over newline Keywords: whitespace in fscanf Message-ID: <449@tardis.Tymnet.COM> Date: 22 Jul 89 09:15:04 GMT References: <19915@louie.udel.EDU> Reply-To: jms@tardis.Tymnet.COM (Joe Smith) Distribution: na Organization: McDonnell Douglas Field Service Co, San Jose CA Lines: 16 In article <19915@louie.udel.EDU> new@udel.EDU (Darren New) writes: >I have a file where each line was written with > char flag1='0', flag2='+', line[80]; > fprintf(file, "%c%c%s\n", flag1, flag2, line[80]); You need to use fscanf(file, "%c%c%s%*c", &flag1, &flag2, line);. The asterisk is mentioned on page F-100 of the Lattice 4.0 manual, under the fscanf/scanf description. It says that the conversion is to be formed (reading the next character) but the result not stored. It snarfs up the whitespace (blank, tab, or newline) that terminated in string read in by the previous "%s". -- Joe Smith (408)922-6220 | SMTP: JMS@F74.TYMNET.COM or jms@tymix.tymnet.com McDonnell Douglas FSCO | UUCP: ...!{ames,pyramid}!oliveb!tymix!tardis!jms PO Box 49019, MS-D21 | PDP-10 support: My car's license plate is "POPJ P," San Jose, CA 95161-9019 | narrator.device: "I didn't say that, my Amiga did!"