title: Tic Tac Toe Program help
body: <p>I am not sure how to proceed from what I have already: I am having trouble getting my array to work and I am also having trouble with my chart reseting everytime i re-run the program. It does not save my X's and O's but restarts into the blank chart. Any hint will be helpful. Thanks</p>
  
  <pre><code>/**
  Lab 4 - Due 7/22/2010.
  
  Convert Lab 3 to a class
  
  1. Implement displayBoard to display Tic Tac Toe board.
  2. Prompt User for a box on the board to select, i.e. a number between 1 and 9 with 1 being the upper left corner.
  
  use cin.get(box) to get the box number and isdigit to verify it is a
  number;
  1 | 2 | 3
  4 | 5 | 6
  7 | 8 | 9
  If the box is available put the appropriate X or O in there and switch players, i.e. X becomes O and vice versa.
  If the box is NOT available warn the user and get another box until they select a valid open box.
  
  3. After all spots have been select Display "Game Over!";
  4. Write a main function to use the TicTacToe class and test all of the above functionality.
  
  **/
  
  
  #include &lt;iostream&gt;
  
  #include &lt;limits&gt;
  
  using namespace std;
  
  
  class TicTacToe {
  public:
      void displayBoard();
      void getMove();
      void playGame();
  private:
      char board[9];
      char player; // Switch after each move.
  };
  
  int main ()
  {
      TicTacToe ttt;
  
      for (int i = 0; i &lt; 9; i++) {
          ttt.playGame();
      }
  }
  
  void TicTacToe::playGame()
  {
      displayBoard();
  
  
      getMove();    
  
      // Your implementation here...
  }
  
  void TicTacToe::displayBoard()
  {
      // Your implementation here...
  
      bool firstMove = true;
      if (firstMove  == true)
      {
  
          for (int i = 0; i &lt; 9; i++) {
              board[i] = i + 1;
          }
  
      }
  
      firstMove == false;
      for (int i = 0; i &lt; 9; i++) 
      {
          if ( (i+1) % 3 == 0 )
          {
              cout &lt;&lt; board[i] &lt;&lt; endl;
          }
          else 
          {
  
              cout &lt;&lt; board[i] &lt;&lt; " | ";
          }
      }
  }
  
  void TicTacToe::getMove()
  {
      if (player == 'X') { 
          player = 'O';
      }
      else {
          player = 'X';
      }
  
      cout &lt;&lt; player &lt;&lt; " ";
      cout &lt;&lt; "Enter Box: ";
      char c;
  
  
      bool move;
      move = true;
  
      do {
          cin.get(c);
          cin.ignore(numeric_limits&lt;int&gt;::max(), '\n');
          if (c &gt; '9' || c &lt; '0')
              // error message
              cout &lt;&lt; "please enter a number 1-9" &lt;&lt; endl;
  
          int number = c - '0';
  
          cout &lt;&lt; "your number is " &lt;&lt; number &lt;&lt; endl;
          // Your implementation here...
  
          if (c == '1' &amp;&amp; board[0] == '1') {
              board[0] = player;
  
              move = false;
          }
          else if(c == '2' &amp;&amp; board[1] == '2')
          {
              board[1] = player;
              move = false;
          }
          else if(c == '3' &amp;&amp; board[2] == '3')
          {
              board[2] = player;
              move = false;
          }
          else if(c == '4' &amp;&amp; board[3] == '4')
          {
              board[3] = player;
              move = false;
          }
          else if(c == '5' &amp;&amp; board[4] == '5')
          {
              board[4] = player;
              move = false;
          }
          else if(c == '6' &amp;&amp; board[5] == '6')
          {
              board[5] = player;
              move = false;
          }
          else if(c == '7' &amp;&amp; board[6] == '7')
          {
              board[6] = player;
              move = false;
          }
          else if(c == '8' &amp;&amp; board[7] == '8')
          {
              board[7] = player;
              move = false;
          }
          else if(c == '9' &amp;&amp; board[8] == '9')
          {
              board[8] = player;
              move = false;
          }
  
      } while (!move);     
  }
  </code></pre>
  
  <p>@Bunnit From your advice i was able to change it up. Now my only problem is replacing each box with an X or O it doesnt seem like my if and else if are working.</p>