delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mailnull set sender to djgpp-bounces using -f |
From: | "A. Sinan Unur" <asu1 AT cornell DOT edu> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: File bad() problem - bug in djgpp or is it me??? |
Date: | 17 Jan 2002 21:53:13 GMT |
Organization: | Cornell University |
Lines: | 53 |
Sender: | asu1 AT cornell DOT invalid (on 180.syracuse-02rh15rt.ny.dial-access.att.net) |
Message-ID: | <Xns9199ABC611E1AASINANUNUR@132.236.56.8> |
References: | <3c47248f DOT 7781706 AT news DOT ntlworld DOT com> |
NNTP-Posting-Host: | 180.syracuse-02rh15rt.ny.dial-access.att.net |
X-Trace: | news01.cit.cornell.edu 1011304393 22232 12.89.10.180 (17 Jan 2002 21:53:13 GMT) |
X-Complaints-To: | usenet AT news01 DOT cit DOT cornell DOT edu |
NNTP-Posting-Date: | 17 Jan 2002 21:53:13 GMT |
User-Agent: | Xnews/L5 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
kevin.dickerson[atnospam]@ntlworld.com (Kevin Dickerson) wrote in news:3c47248f DOT 7781706 AT news DOT ntlworld DOT com: > #include<iostream.h> > #include<fstream.h> > #include<string.h> use the new style headers, especially when it comes to string. string.h and string are very different (in C++, string.h corresponds to cstring, AFAIK). that said, I can't replicate your problem (with djgpp v.2.03 and gcc 2.95.3). the code below incorporates my suggested modifications. it also exhibits the desired behavior: C:\var>cat fs.cc #include<iostream> #include<fstream> using std::ifstream; using std::cerr; using std::cout; using std::endl; using std::ios; int main (void) { int x=0; ifstream open_file; open_file.open ("Test"); if (open_file.bad()) { cerr << "Error: Could not open the file" << endl; x=1; } cout <<x<< endl; if (open_file.is_open()) open_file.close(); } C:\var>gpp fs.cc -o fs.exe -Wall C:\var>fs Error: Could not open the file 1 -- -------------------------------- A. Sinan Unur http://www.unur.com/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |