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

16 lines
401 B
C++
Raw Normal View History

#include <iostream.h>
#include <fstream.h>
void main( void ) {
fstream test ( "temp.txt", ios::in );
test.exceptions( ios::failbit );
try {
test >> "Hello my world"; /* failbit will be set if "temp.txt"
is empty */
}
catch( ios::failure ) {
cout << "The previous operation on the stream fails!" << endl;
}
}