solved

solved. thanks a lot
Last edited on
1
2
3
4
5
6
7
8
9
10
11
while(cin>>filename)
{
      if(!filename)
      {
         //error message
       }
       else
      {
        //main body
       }
}


try something like that it would allow you to continue looping through your input loop. also probably would want to put the rest of your code in the else statement so that after checking if the file name does not exist and if it does than it goes to the else statement and runs the code you want. Let me know if this steered you in the right direction
Last edited on
1
2
3
4
5
    do { //input validation
        cout << "Please enter the name of the file: "; // ask the user to input file name
        cin >> fileName;
        inputFile.open(fileName); // open the file
    } while (!inputFile);
Topic archived. No new replies allowed.