Checking if open function is NULL and ifstream object's fail : ifstream « File « C++
- C++
- File
- ifstream
Checking if open function is NULL and ifstream object's fail

#include <fstream>
#include <iostream>
using namespace std;
int main ()
{
ifstream infile;
infile.open("students.dat");
cout << "(infile) = " << infile << endl;
cout << "(infile.fail()) = " << infile.fail() << endl;
return 0;
}
Related examples in the same category