home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / c / 12813 < prev    next >
Encoding:
Text File  |  1992-08-26  |  1.3 KB  |  48 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!nntp.msstate.edu!Ra.MsState.Edu!cee1
  3. From: cee1@Ra.MsState.Edu (Charles Evans)
  4. Subject: Reading from text file
  5. Message-ID: <1992Aug26.194501.4929@ra.msstate.edu>
  6. Sender: news@ra.msstate.edu
  7. Nntp-Posting-Host: ra.msstate.edu
  8. Organization: Mississippi State University
  9. Date: Wed, 26 Aug 1992 19:45:01 GMT
  10. Lines: 36
  11.  
  12. Ok, needing to read x number of lines of a data file with 2 integers
  13. on each line (not knowing the # of lines).. so my deal is to figure
  14. out an EOF checker.. here is what i am trying to do.. any pointers of
  15. this matter will be most appreciative very quickly....
  16.  
  17. .....
  18. FILE *fp
  19. int Index = 0;
  20. int Looper;
  21. char year[100];      /* would rather use a pointer, not knowing how big itis
  22. char value[100];     /* same */
  23.  
  24. fp = fopen("foo.dat","r"); 
  25.  
  26. while (fp != EOF)
  27. {
  28.     fgets(fp,"%d",year[Index]);
  29.          fgets(fp,"%d",value[Index]);
  30.     Index++;
  31. }
  32. for (Looper = 0; Looper = Index; Looper++)
  33. {
  34.     printf("Values: %d and d\n",year[Looper],value[Looper]);
  35. }.
  36.  
  37. .,...
  38.  
  39. thanks
  40.  
  41. chuck
  42.  
  43. --
  44. +--------------------+-----------------------+------------------------+
  45. |  Charles E. Evans  |  cee1@ra.msstate.edu  |  All things are green  |
  46. |    iDLE CHATTEr    |  cee1@MSSTATE.BITNET  |  unless they are not.  |
  47. +--------------------+-----------------------+------------------------+
  48.