home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!destroyer!gatech!rpi!usenet.coe.montana.edu!sandy
- From: sandy@cs.montana.edu (Sandy Pittendrigh)
- Subject: fgets() sscanf() EOF confusion
- Message-ID: <1992Dec30.160832.3769@coe.montana.edu>
- Sender: usenet@coe.montana.edu (USENET News System)
- Organization: Dept. of Computer Science, MSU, Bozeman Mt 59717
- Date: Wed, 30 Dec 1992 16:08:32 GMT
- Lines: 20
-
- I know how to read a text file one character at a time,
- and how to jump out of a loop when EOF is encountered,
-
- but I'd like to do something like the following, and don't
- know how to detect EOF when using fgets and sscanf.
-
-
- while(!feof(inFile))
- {
- fgets(line,80,inFile);
- sscanf(line,"%d %d %d %d", &x, &y, &z);
- if(eof(inFile) /* But this doesn't work */
- {
- doSomething(x,y,z);
- break;
- }
- else doSomething(x,y,z);
- }
-
- Is this a resonable concept?
-