home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 19025 < prev    next >
Encoding:
Text File  |  1992-12-30  |  863 b   |  31 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!destroyer!gatech!rpi!usenet.coe.montana.edu!sandy
  3. From: sandy@cs.montana.edu (Sandy Pittendrigh)
  4. Subject: fgets() sscanf() EOF confusion
  5. Message-ID: <1992Dec30.160832.3769@coe.montana.edu>
  6. Sender: usenet@coe.montana.edu (USENET News System)
  7. Organization: Dept. of Computer Science, MSU, Bozeman Mt 59717
  8. Date: Wed, 30 Dec 1992 16:08:32 GMT
  9. Lines: 20
  10.  
  11. I know how to read a text file one character at a time, 
  12. and how to jump out of a loop when EOF is encountered,
  13.  
  14. but I'd like to do something like the following, and don't 
  15. know how to detect EOF when using fgets and sscanf.
  16.  
  17.  
  18. while(!feof(inFile))
  19.   {
  20.   fgets(line,80,inFile);
  21.   sscanf(line,"%d %d %d %d", &x, &y, &z);
  22.   if(eof(inFile) /* But this doesn't work */
  23.    {
  24.    doSomething(x,y,z);
  25.    break;
  26.    }
  27.   else doSomething(x,y,z);
  28.   }
  29.  
  30. Is this a resonable concept? 
  31.