hi
I have wrote this method to read files the question is about this code here
I know my method doesn't return any think because it is void so how would I exit this method safely if the file cannot be found?
Any help would be appreciated
I have wrote this method to read files the question is about this code here
if( fileName.fail() ) { cerr << "Cannot open file: " << endl; system( "PAUSE" ); return( 1 ); }
I know my method doesn't return any think because it is void so how would I exit this method safely if the file cannot be found?
Any help would be appreciated
void ReadFile::getInfo() { string info; fileName.open( "Test.txt" ); if( fileName.fail() ) { cerr << "Cannot open file: " << endl; system( "PAUSE" ); return( 1 ); } fileName >> info; cout << info << endl; }