Mail Archives: djgpp/2001/12/27/11:47:55
X-Authentication-Warning: | delorie.com: mailnull set sender to djgpp-bounces using -f
|
From: | Nithyanandham <m DOT nithyanandham AT blr DOT spcnl DOT co DOT in>
|
Newsgroups: | comp.lang.c++,comp.os.msdos.djgpp
|
Subject: | Re: Reopening ifstream objects
|
Date: | Thu, 27 Dec 2001 22:10:33 +0530
|
Organization: | Siemens Inc.
|
Lines: | 37
|
Message-ID: | <3C2B4F01.1ED81A5D@blr.spcnl.co.in>
|
References: | <a0dv9g$ac6 AT cs DOT vu DOT nl>
|
NNTP-Posting-Host: | 132.186.66.212
|
Mime-Version: | 1.0
|
X-Mailer: | Mozilla 4.72 [en] (WinNT; I)
|
X-Accept-Language: | en
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
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.
ifstream fin(file_name) ;
if(!fin)
{
cout<< "Don't do this"<<endl ;
}
if( !fin.is_open())
{
cout<<"Do this to check the status"<<endl ;
}
I doubt you have done the previous one and not the latter one. So, change your
code accordingly
and come back here with your results.
--
Nithyanand.
Siemens, Bangalore, India.
(Opinions expressed are my own and do not reflect the opinions of my employer,
Siemens)
- Raw text -