solved

Mar 4, 2013 at 5:54am
solved. thanks a lot
Last edited on Mar 4, 2013 at 4:35pm
Mar 4, 2013 at 6:04am
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 Mar 4, 2013 at 6:05am
Mar 4, 2013 at 6:14am
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.