title: Storing locations in Array as a variable to be changed in a if statement
body: <p>Is there a way to store the x and y entered by the user into a location for the array.</p>
  
  <p>I have this:</p>
  
  <pre><code>if (x == 1 &amp;&amp; y == 1)
          {
              board[0][0] = playerMarker;
          } 
  </code></pre>
  
  <p>I want to make it so the x and y are stored into a variable that matches the name of a spot in an array.</p>
  
  <p>But I want to try and make it more like this:</p>
  
  <pre><code>if (currentMove == '1' &amp;&amp; squareOne == '1')
                  squareOne = playerMarker;
  </code></pre>
  
  <p>This is a code I have seen above. The code bellow is my own.</p>
  
  <pre><code>void playerMove(char* CurrentPlayer, char (&amp;board)[3][3], char &amp;playerMarker)
      {
          bool bValidMove;
          int x,y;
      // Prompt the player for a move
      cout &lt;&lt; "Player " &lt;&lt; CurrentPlayer &lt;&lt; "'s move:" &lt;&lt; endl;
  
  
  
      // Loop until we get a valid move
      do 
      {
          cout &lt;&lt; "Please enter the row number for the place you wish to mark: " &lt;&lt; endl;
          cin &gt;&gt; x;
          cout &lt;&lt; "Please enter the column number for the place you wish to mark" &lt;&lt; endl;
          cin &gt;&gt; y;
          bValidMove = true;
  
          // Check for a valid move
          if (x == 1 &amp;&amp; y == 1)
          {
              board[0][0] = playerMarker;
          } 
          else if (x == 1 &amp;&amp; y == 2) 
          {
              board[0][1] = playerMarker;
          } 
          else if (x == 1 &amp;&amp; y == 3) 
          {
              board[0][2] = playerMarker;
          }
          else if (x == 2 &amp;&amp; y == 1) 
          {
              board[1][0] = playerMarker;
          }
          else if (x == 2 &amp;&amp; y == 2)
          {
              board[1][1] = playerMarker;
          }
          else if (x == 2 &amp;&amp; y == 3)
          {
              board[1][2] = playerMarker;
          }
          else if (x == 3 &amp;&amp; y == 1)
          {
              board[2][0] = playerMarker;
          }
          else if (x == 3 &amp;&amp; y == 2)
          {
              board[2][1] = playerMarker;
          }
          else if (x == 3 &amp;&amp; y == 3) 
          {
              board[2][2] = playerMarker;
          }
          else 
          {
              cout &lt;&lt; "Invalid Move. Try again." &lt;&lt; endl;
              bValidMove = false;
          }
  
      } 
      while (!bValidMove);
  
  }
  </code></pre>
  
  <p>This is the code I am trying to make my own into.</p>
  
  <pre><code>// Ask current player for a move
          cout &lt;&lt; currentPlayer &lt;&lt; "'s move: ";
          bool validMove;
          // Loop until a valid move is chosen
          do
          {
              char currentMove;
              cin &gt;&gt; currentMove;
              validMove = true;
  
              // Check for a valid move
              if (currentMove == '1' &amp;&amp; squareOne == '1')
                  squareOne = playerMarker;
              else if (currentMove == '2' &amp;&amp; squareTwo == '2')
                  squareTwo = playerMarker;
              else if (currentMove == '3' &amp;&amp; squareThree == '3')
                  squareThree = playerMarker;
              else if (currentMove == '4' &amp;&amp; squareFour == '4')
                  squareFour = playerMarker;
              else if (currentMove == '5' &amp;&amp; squareFive == '5')
                  squareFive = playerMarker;
              else if (currentMove == '6' &amp;&amp; squareSix == '6')
                  squareSix = playerMarker;
              else if (currentMove == '7' &amp;&amp; squareSeven == '7')
                  squareSeven = playerMarker;
              else if (currentMove == '8' &amp;&amp; squareEight == '8')
                  squareEight = playerMarker;
              else if (currentMove == '9' &amp;&amp; squareNine == '9')
                  squareNine = playerMarker;
              else
              {
                  cout &lt;&lt; "Invalid Move. Try again: ";
                  validMove = false;
              }
          } while ( !validMove );
  </code></pre>