X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: kevin.dickerson[atnospam]@ntlworld.com (Kevin Dickerson) Newsgroups: comp.os.msdos.djgpp Subject: File bad() problem - bug in djgpp or is it me??? Message-ID: <3c47248f.7781706@news.ntlworld.com> X-Newsreader: Forte Free Agent 1.21/32.243 Lines: 33 Date: Thu, 17 Jan 2002 19:23:23 GMT NNTP-Posting-Host: 213.107.239.25 X-Complaints-To: abuse AT ntlworld DOT com X-Trace: news2-win.server.ntlworld.com 1011295336 213.107.239.25 (Thu, 17 Jan 2002 19:22:16 GMT) NNTP-Posting-Date: Thu, 17 Jan 2002 19:22:16 GMT Organization: ntlworld News Service To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I compiled the code below initially in Borland C++, and it worked fine, if the file didn't exist then it returned an error. However when I compile it with djgpp, it doesn't return an error and just carries on as normal. The only way i have managed to get round it is by using "if(open_file==NULL)". Which is fine, but I do not think it is closing the file either, which can become a problem when you want to open another file. Is it something I'm doing wrong or is it something in djgpp. Kevin #include #include #include ifstream open_file; int main (void) { int x=0; open_file.open ("Test"); if (open_file.bad()) { cerr << "Error: Could not open the file\n"; x=1; } cout<