C++ ifstream bad()

Description

C++ ifstream bad()

#include <fstream>          // for file functions
#include <iostream>
using namespace std;
int main()//w  ww .j  a v a2s.  com
{
   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;
}



PreviousNext

Related