User Tools

Site Tools


c_-_c_files:file_opening_errors

C - C++ Files - File opening errors

#include <fstream>
#include <iostream>  
using namespace std;  
 
int main()
{
  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;  
}
c_-_c_files/file_opening_errors.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki