1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
char confirmCar='n';
while((confirmCar!='y')||(confirmCar!='Y')||(confirmCar!='q')||(confirmCar!='Q')){
// system("cls");
cout<<"Please enter Car's model:"; //Input
cin.getline(newCar.model,21);
cout<<"Please enter license tag:";
cin>>newCar.license;
cin.ignore(1000,'\n');
cout<<"Add car '"<<newCar.model<<"' with license tag '"<<newCar.license<<"'? (Y/n/q):";
cin.get(confirmCar).ignore(1000,'\n'); //check
cout<<confirmCar;//Debug
}//While
| |
For some reason it won't end the loop even when ConfirmCar outputs y. Any form of help or hint would be very very appreciated.
Edit: This is a c++ questions, however I'm using cstrings.
Last edited on
You need to use &&
rather than ||
to combine the separate conditions in the while statement.
Currently, if the user enters 'y', the first condition is false, but the other three are true. Combined using a logical OR, the result is always true.