Here is my code. I want it to ask for the name of file until it is a valid name. How will I do it? In my current code it stops after the fail.
void X() {
string fileName;
ifstream inFile;
cout << "Enter the name of the file: " << endl;
cin >> fileName;
ifstream input;
input.open(fileName);
if (input.fail()) {
cout << "Could not open the file " << fileName << endl;
}
}