0

Hello,
So I'm just starting to learn c++ and am trying to make a tic tac toe game. My problem is where it says (board[pMove - 1] != 'X' || 'O'); it's supposed to see if there is already an x or o in the spot and then place the x, but when I run the program it just prompts another input for pMove and doesn't place the x.

thanks for any help

p.s. I'm trying not to look at other tic tac toe source code so that I can figure it out on my own

void playersMove() // Player's move
{
     cout << "X: ";
     cin >> pMove; // Player inputs which space to put 'X'
     if (board[pMove - 1] != 'X' || 'O') // Tests whether there is already an 'X' or 'O' in spot
        board[pMove - 1] = 'X'; // If the spot is clear, an 'X' is put in the spot
     else
         cout << "Invalid move. \n"; // If the spot is taken, prompt another input
     playersMove();
     }
1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Art_Vandelay
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.