RE: RE: [Dev-C++] first time error return on checking file stream validity
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: James G. <Jam...@Cl...> - 2001-01-02 16:02:46
|
Try http://www.dinkumware.com/htm_cpl/fstream.html#basic_ifstream for info on ifstream take off fstream.html... to see the whole C++ Library reference. Regards, James. -----Original Message----- From: Alan Thomas [mailto:ala...@3n...] Sent: Tuesday, January 02, 2001 3:45 PM To: dev...@li... Subject: re: RE: [Dev-C++] first time error return on checking file stream validity James, Where can I find all the operations (e.g., check with "is_open") I can do on stream objects? Thanks, Alan From: James Gordon <Jam...@Cl...> The reason you are not getting an error the first time you access invalid is because when it is created the state bits are set to 'good'. After you have tried to write out the state is not 'bad'. If you were to test and return if the stream isn't open (is_open() returns true if the file pointer is not a null pointer). if (!output_file.is_open()) { cout << "Error opening file." << endl; return 1; // error indication } _______________________________________________ Dev-cpp-users mailing list Dev...@li... http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This electronic message and any attachment is intended to be read by the named addressee(s) only. Any other recipient should be aware that its contents may be legally privileged and/or confidential and that its use, disclosure, copying or distribution may be unlawful. Unless you are a named addressee, please delete this message Whilst C. & J. Clark International Limited has taken steps to prevent the transmission of computer viruses with electronic mail, responsibility for screening incoming messages and the risk of such transmission and its consequences lies with the recipient. C. & J. Clark International Limited Registered in England and Wales Company No. 141015 Registered Office: 40 High Street, Street, Somerset BA16 0YA Telephone: +44 (0) 1458 443131 Fax: +44 (0) 1458 447547 |