hi im 17 and trying to teach myself c++. For one of my first projects I am trying to write a tic-tac-toe game and play vs an AI. So the code im having trouble with is this
main() {
char player, computer;
while (player != 'x' || player != 'o' )
{
cout << "do you want to be x or o?";
cin >> player;
};
if (player == 'x' ) computer == 'o';
else computer == 'x';
cout << "player is: " << player << endl << "computer is: " << computer ;
cout << computer;
};
I get the message " do you want to be x or o?", but then I enter x or o and it keeps repeating the same question. I think it has to do with the while loop. Any help is appreciated.
Your loop end condition is wrong, and you shouldn't check until you've asked once.
do {
cout << "do you want to be x or o?";
cin >> player;
} while (player != 'x' && player != 'o');