...instead of crashing without any error messages
std::ifstream ifs (mystr, std::ios::in | std::ios::binary);
if (ifs.is_open()) {
cout<<"The file is read successfully! :)"<<endl;}
else {
// show message:
cout << "Error opening file!"<<endl;
cout << "The file cannot be found in the given path."<<endl;
cout<< "The program will be closed." <<endl;
system("PAUSE") ;
exit(EXIT_FAILURE);
}
std::ifstream ifs (mystr, std::ios::in | std::ios::binary);
if (ifs.is_open()) {
cout<<"The file is read successfully! :)"<<endl;}
else {
// show message:
cout << "Error opening file!"<<endl;
cout << "The file cannot be found in the given path."<<endl;
cout<< "The program will be closed." <<endl;
system("PAUSE") ;
exit(EXIT_FAILURE);
}
No comments:
Post a Comment