I'm at a loss of what to do here. So I have this simple while loop meant to allow a user to re-input a number if they accidentally give an incorrect input. The issue is, if you input "2" it loops back again. I can't, for the life of me figure it out.
void Player::playerPick()
{
int selection = 0;
while (selection != (1 || 2))
{
cout << "Player 1 or Player 2 (Type [1] or [2])";
cin >> selection;
}
}
while (selection != 1 && selection != 2)(1 || 2)istrue. You wrotewhile(selection != true). Many compilers issue a warning.(selection!=1 || 2). That's not a duplicate because it means((selection!=1) || 2)()), and that the answer is also fundamentally the same.