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/opexam.cpp

19 lines
469 B
C++
Raw Normal View History

#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.operator !() ) {
cout << "The previous operation on the stream fails!" << endl;
}
}