I've written this loop I'm not sure if while was the best way to go about it but anyway... The problem is that it only half works.. If I enter "p" or "c" once it will still execute the while loop. However if I put p or c in a second time it will then return. If I put in anything else it will keep executing the while loop. What is going on here?
1 2 3 4 5 6 7 8 9 10 11 12 13
void add()
{
string type;
cout << "Permanent or Casual? (p/c)" << endl;
cin >> type;
while (type != "p" || type != "c"){ //maybe change to for?
cout << "Invalid type. Please enter either p (permanent) or c (casual)" << endl;
cin >> type;
if(type == "p" || type == "c"){
return;
}
}
}