[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: Re: File input problem
Hi
I too checked out & I'm also getting the same problem. It looks so
silly. The problem is inFile.good() is returning 1 eventhough end of file
has reached. Thus inFile.get() is reading the extra character. The
character that's being read is DEL (Control Character). I'd expect
inFile.good() to return 0 if the next character would return
end-of-file. But that's not happening here. I tried with feof() & got the
same result.
I dunno what I'm missing here. Let me know if u find the answer.
Sreeji
On Tue, 21 Nov 2000, Ashwin wrote:
> Hi,
>
> >> for( int j = 0; j < i; ++j )
> >
> >Make that j < i - 1 and you should be fine.
>
> I checked.. (j < i) is right.
>
> >Maybe that is wrong. I am using my C concepts here (assuming
> infile.good()
> >method equivalent to the stdio function feof()).
>
> I even tried (!infile.eof())
>
> >> <test.txt contents>
> >> linux
> >> <test.txt contains *only* five characters>
> >
> >six, my friend, there is a newline at the end.
>
> I checked it with the HEX editor in KDE, this file had five
> chars.
>
> This silly problem is eating my head :)
>
> Ashwin
>
>
> ---------------------------------------------
> The mailing list archives are available at
> http://lists.linux-india.org/cgi-bin/wilma/LIP
>