ofstream.fail() Demo
#include <fstream> #include <iostream> using namespace std; int main () { ofstream outfile; outfile.open("file.dat"); cout << "( outfile) = " << outfile << endl; cout << "( outfile.fail()) = " << outfile.fail() << endl; return 0; }