while (chart[row_num][seat_num] == '*')
{
cout << "The position you picked is filled. Please enter another row number: ";
cin >> row_num;
}
This code will check the condtion and then ask for the user input, however you need to do the exact opposite. You need to ask for input, and then check the condition.
This can be done by asking for row_num input before your while loop, and also after the input is invalid
i.e.
cin>>row_num; //get input
while (chart[row_num][seat_num] == '*') //check condition
{
cout << "The position you picked is filled. Please enter another row number: ";
cin >> row_num; //keep getting input if it condition is false
}
The code above however seems a little repetitive, you can fix this by asking for input within the actually while loop condition.
while (cin >> row_num && chart[row_num][seat_num] == '*') cout << "The position you picked is filled. Please enter another row number: ";
This post has been edited by jjl: 16 December 2012 - 06:48 PM

New Topic/Question
Reply




MultiQuote




|