If not true, prompt again until is true
This is so easy, but I am drawing a blank right now (long day). I simply
need this part of the code to reprompt for a file name if the one entered
is not valid or is bad.
cout << "Please enter a file name:" << endl;
string filename;
string line;
cin >> filename;
ifstream in_file;
in_file.open(filename.c_str());
if (in_file.good())
{
getline (in_file, line);
cout << line << endl;
in_file.close();
}
No comments:
Post a Comment