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();
     }

Just realized what I did wrong.

needed == instead of =

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.