Problem reading data from a file (encounter EOF after second last record)



Hi Everybody,

I am reading data from a file. I know the number of records in the
file and can read all the records except for the last. Using IOSTAT
in the READ statement shows that EOF is encountered after reading the
second last record. I am baffled a bit. I think it has to do something
with the program which created the datafile in the first place, but I
do not want to touch that program as far as possible. Could anybody
pull me out of the problem.

(for example, following is the structure of my datafile. I can read
the second last line, but not the last)

0.00000000000000E+000 1 5.00E-008
5.00000000000000E-004 2 5.90E-008
1.08988019155737E-003 3 6.96E-008
1.78579747234089E-003 4 8.21E-008
2.60681311013423E-003 5 9.69E-008
3.57541483352048E-003 6 1.14E-007
4.71813277378826E-003 7 1.35E-007
6.06626612879065E-003 8 1.59E-007
7.65674045217803E-003 9 1.88E-007
9.53311904927169E-003 10 2.21E-007
1.17467961818472E-002 11 2.61E-007

Regards,
Nure
.



Relevant Pages

  • Re: Problem reading data from a file (encounter EOF after second last record)
    ... I am reading data from a file. ... following is the structure of my datafile. ... Check that the file ends with a proper end-of-line character sequence. ... For Fortran programs this poses a significant problem, ...
    (comp.lang.fortran)
  • Re: Can I read and write after EOF in a File
    ... data - so that's going to stop you reading data, ... there but I want to write after EOF bit. ... you think requires writing "after" EOF and which you distinguish ... Thanks Richard Heathfield, ...
    (comp.lang.c)
  • Re: Can I read and write after EOF in a File
    ... When a function returns EOF, it means it couldn't read any more data ... - so that's going to stop you reading data, ... fwrite, fFile); ... Are you really surprised that there's no data past that ...
    (comp.lang.c)
  • Re: Can I read and write after EOF in a File
    ... When a function returns EOF, it means it couldn't read any more ... data - so that's going to stop you reading data, ... Yes In append mode it gets to the end of file and then write it ... you think requires writing "after" EOF and which you distinguish ...
    (comp.lang.c)
  • Re: Can I read and write after EOF in a File
    ... Ben Bacarisse said: ... data - so that's going to stop you reading data, ... Nit: I think you can read data after you encounter EOF. ...
    (comp.lang.c)