Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!wa4mei!nanovx!msa3b!mgphl From: mgphl@msa3b.UUCP (Michael Phillips) Newsgroups: comp.misc Subject: Re: rn file format Message-ID: <1608@msa3b.UUCP> Date: 18 Apr 91 00:07:13 GMT References: <1991Apr8.194705.1225@ico.isc.com> <1991Apr14.024245.23227@skypod.uucp> Organization: Dun and Bradstreet Software, Inc., Atlanta, GA Lines: 49 marc@skypod.uucp (Marc Fournier) writes: >Hi Folks, > I presume someone out there knows the answer to this question... >I'm writing a program that needs to read in the records in .newsrc, but >I'm having serious problems doing so. I'm using fscanf, which I presume >is correct, because it is reading half of it in. > the format that I am using is fscanf(f1,"%s %d", group, upper), but >it seems to only read in the group, pass through the loop fine and then >read the upper (the numeric component). I want it to read both in at >once. Marc, heres some code that seems to understand what it read: #include int main( argc, argv ) int argc; char *argv[]; { int rc = 0, low = 0, high = 0; char group[50]; FILE *in; in = fopen( argv[1], "r" ); if (!in) return -1; while ( rc != 3 ) { rc = fscanf( in, "%s %d-%d", group, &low, &high ); printf( "rc: %d, group: %s, low: %d, high: %d\n", rc, group, low, high ); low = high = 0; } fclose( in ); return 0; } Hope it helps.... Michael ****************************************************************************** | Michael G. Phillips | "Only two things are infinite, the universe | | Dun & Bradstreet Software | and human stupidity, and I'm not sure about | | ..!gatech!nanovx!msa3b!mgphl | the former" -- Albert Einstein | ******************************************************************************