From: krhohio AT my-deja DOT com Newsgroups: comp.os.msdos.djgpp Subject: Re: seekg() bug Date: Wed, 09 Aug 2000 02:14:19 GMT Organization: Deja.com - Before you buy. Lines: 36 Message-ID: <8mqepq$s50$1@nnrp1.deja.com> References: <8mg9j5$fis3 AT imsp212 DOT netvigator DOT com> <38nnos876cfdjok9gbkn9sn7968nnjh054 AT 4ax DOT com> NNTP-Posting-Host: 12.23.19.70 X-Article-Creation-Date: Wed Aug 09 02:14:19 2000 GMT X-Http-User-Agent: Mozilla/4.05 [en] (WinNT; I) X-Http-Proxy: 1.0 x68.deja.com:80 (Squid/1.1.22) for client 12.23.19.70 X-MyDeja-Info: XMYDJUIDkrhohio To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I seem to be having the same problem using Microsoft VC++ 6.0 to compile a "console application". I called "bad()" after detecting "eof()" and it returns false (as expected). Do I need to add "clear()" after eof is detected? Thanks, Kent In article <38nnos876cfdjok9gbkn9sn7968nnjh054 AT 4ax DOT com>, Jason Green wrote: > "David Lee" wrote: > > > I opened a fstream object and tried to position the file pointer with seekg > > (). > > > > I found that seekg () always worked as long as eof () was not encountered. > > Once eof () holds, it would appear to work as usual, but subsequent reading > > from the fstream object were wrong. > > > > Any idea? > > You are not checking the stream for errors. The stream state can be > tested with (f), f.good(), f.eof(), f.fail() & f.bad(), which each > have a specific meaning. > > My C++ reference says that if fail() is true the next operation will > fail. The state bits can be reset with f.clear(). > Sent via Deja.com http://www.deja.com/ Before you buy.