delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/08/05/06:00:31

From: Jason Green <news AT jgreen4 DOT fsnet DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: seekg() bug
Date: Sat, 05 Aug 2000 10:37:25 +0100
Organization: Customer of Energis Squared
Lines: 17
Message-ID: <38nnos876cfdjok9gbkn9sn7968nnjh054@4ax.com>
References: <8mg9j5$fis3 AT imsp212 DOT netvigator DOT com>
NNTP-Posting-Host: modem-129.oxygen.dialup.pol.co.uk
Mime-Version: 1.0
X-Trace: news7.svr.pol.co.uk 965468945 3815 62.136.7.129 (5 Aug 2000 09:49:05 GMT)
NNTP-Posting-Date: 5 Aug 2000 09:49:05 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Newsreader: Forte Agent 1.7/32.534
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"David Lee" <keeyu AT poetic DOT com> 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().

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019