This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/cplbexam/ios/rdstate.cpp

20 lines
529 B
C++

#include <iostream.h>
#include <fstream.h>
void main( void ) {
fstream test ( "temp.txt", ios::in|ios::out ); // S1
/* S2: fstream test ("temp.txt", ios::in);
Compare the results by using S2 instead of S1 */
if( !test.bad() ) {
test << "Hello my world!" << endl;
cout << "\"temp.txt\" is created." << endl;
}
if( test.fail() ) {
cout << "The previous operation on the stream fails!" << endl;
}
cout << "The current iostate: " << test.rdstate() << endl;
}