C++ ifstream fail()
#include <fstream> // for file functions #include <iostream> using namespace std; int main()//from w w w .j a v a 2 s. c o m { ifstream file; file.open("a:test.dat"); if( !file ) cout << "\nCan't open GROUP.DAT"; else cout << "\nFile opened successfully."; cout << "\nfile = " << file; cout << "\nError state = " << file.rdstate(); cout << "\ngood() = " << file.good(); cout << "\neof() = " << file.eof(); cout << "\nfail() = " << file.fail(); cout << "\nbad() = " << file.bad() << endl; file.close(); return 0; }