I setup a while loop where i want to choose r or h, i dont want to use forloops but i want to use a switch why is it when i enter r or h it keeps repeating a million times the cout for that case? I cant get it to just say it once..
while (chooseMove == 'r' or 'h')
{
switch (chooseMove)
{
case 'r':
cout << "you chose r";
break;
case 'h':
cout << "you chose h";
break;
}
}
I also tried it with forloops and had the same problem i cant figure it out
What you mean is
while (chooseMove == 'r' or chooseMove == 'h'). What you’ve currently written is equivalent to((chooseMove == 'r') or ('h')), and'h'evaluates astrue.Maybe you were also asking for help with the input logic:
This will also terminate if the input stream is closed, and you can use
successto inspect the success of the operation.