Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!gatech!udel!mmdf From: Ata@multics.radc.af.mil (John G. Ata) Newsgroups: comp.sys.amiga Subject: Re: C scanf question Message-ID: <20199@louie.udel.EDU> Date: 21 Jul 89 20:13:21 GMT Sender: mmdf@udel.EDU Lines: 31 Delivery-Date: 20 July 1989 09:17 edt Delivery-By: Network_Server.Daemon (amiga-relay-request@louie.udel.e) Sender: amiga-relay-request at UDEL.EDU Date: Wednesday, 19 July 1989 17:45 edt From: Charles Brown Subject: Re: C scanf question To: amiga-relay at UDEL.EDU Newsgroups: comp.sys.amiga Organization: Hewlett-Packard Co., Corvallis, Oregon > I'm trying to read it back into the same variables one line at a time. > I've tried > fscanf(file, "%c%c%s\n", &flag1, &flag2, line); > fscanf(file, "%c%c%s ", ...); > fscanf(file, " %c%c%s", ...); > fscanf(file, "\n%c%c%s", ...); > I'm well versed in C but usually have avoided the STDIO routines for > various reasons in the past. Can anyone tell me what I'm doing wrong? > -- Darren Sounds like you're forgetting the at the end of an input line. Thus, the second time through the loop, the will be the first character of input. To get around this problem, do an extra getc after you do the fscanf to eliminate the . Then it should work properly. For the fscanf, "%c%c%s" should do as format effectors. John G. Ata