|This is a homework assignment. For part of my assignment I have to ask the user for a file|
name (contains spaces) and then test to see if the file is valid if not loop it and ask the user if they want to enter in a different file name. If they don't, exit, if they do test it again to see if it is valid.
Below is my code for that part of the program. The loop created will not let the user re-enter a file name. I could use some help in figuring out how to fix it.
cout << "Please enter the file name including the file extension
for this \n"
<< "years rainfall: ";
getline(cin, ActFileName); //get file name
while(ActFin.fail()) //test file
// if file failed ask the user if they want to try again
cout << "File name is invalid. Would you like to enter another file name?"
<<" 'y' or 'n' \n";
cin >> yn;
if (yn == 'y')
//If user wants to re-enter file name ask and get the new file name
cout << "Plese re-enter the file name for this years rainfall: \n";
else //if user says no, exit