home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!nntp.msstate.edu!Ra.MsState.Edu!cee1
- From: cee1@Ra.MsState.Edu (Charles Evans)
- Subject: Reading from text file
- Message-ID: <1992Aug26.194501.4929@ra.msstate.edu>
- Sender: news@ra.msstate.edu
- Nntp-Posting-Host: ra.msstate.edu
- Organization: Mississippi State University
- Date: Wed, 26 Aug 1992 19:45:01 GMT
- Lines: 36
-
- Ok, needing to read x number of lines of a data file with 2 integers
- on each line (not knowing the # of lines).. so my deal is to figure
- out an EOF checker.. here is what i am trying to do.. any pointers of
- this matter will be most appreciative very quickly....
-
- .....
- FILE *fp
- int Index = 0;
- int Looper;
- char year[100]; /* would rather use a pointer, not knowing how big itis
- char value[100]; /* same */
-
- fp = fopen("foo.dat","r");
-
- while (fp != EOF)
- {
- fgets(fp,"%d",year[Index]);
- fgets(fp,"%d",value[Index]);
- Index++;
- }
- for (Looper = 0; Looper = Index; Looper++)
- {
- printf("Values: %d and d\n",year[Looper],value[Looper]);
- }.
-
- .,...
-
- thanks
-
- chuck
-
- --
- +--------------------+-----------------------+------------------------+
- | Charles E. Evans | cee1@ra.msstate.edu | All things are green |
- | iDLE CHATTEr | cee1@MSSTATE.BITNET | unless they are not. |
- +--------------------+-----------------------+------------------------+
-