www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/12/28/02:50:48

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
Date: Fri, 28 Dec 2001 09:29:06 +0200 (WET)
From: Andris Pavenis <pavenis AT lanet DOT lv>
X-Sender: pavenis AT ieva06
To: Nithyanandham <m DOT nithyanandham AT blr DOT spcnl DOT co DOT in>
Cc: djgpp AT delorie DOT com
Subject: Re: Reopening ifstream objects
In-Reply-To: <3C2B517E.698C901C@blr.spcnl.co.in>
Message-ID: <Pine.A41.4.05.10112280925070.34494-100000@ieva06>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com


On Thu, 27 Dec 2001, Nithyanandham wrote:

> 
> 
> Nithyanandham wrote:
> 
> > J wrote:
> >
> > > If the construction of an ifstream object fails in the sense that its boolean
> > > value has become false (e.g. because the supplied file doesn't exist), but
> > > later on its member function open is successfully called, should the boolean
> > > value of the object be true again? If it should, my compiler (DJGPP 3.02) has
> > > a bug.
> >
> > When you open the files using ifstream constructor , the failbit is not affected.
> >
> > You should check the failbit status with is_open() member function.
> 
> Typo. It should be
> You should check the whether it was succesful or failed with is_open() member
> function.
> 

Perhaps one should try something like (untested):
	
	char ch;
	ifstream foo ("file1");
	while ( foo.get(ch) ) ;
	foo.close ();
	foo.clear ();
	foo.open (....)

Andris




- Raw text -


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