title: Help Turning C++ coding into Function
body: <p>SigTerm said this:
  "Smells like a bad code. squareOne..squareSix should be probably array. Instead of char constants, enums or ints should be probably used... "
  How do i do that with this code for the board also if someone could suggest the code I would have to use to get users to enter the row and column for the X and O for the game.</p>
  
  <pre><code>void showboard(char &amp;squareOne, char &amp;squareTwo, char &amp;squareThree, char &amp;squareFour, char &amp;squareFive, char &amp;squareSix, char &amp;squareSeven,
                  char &amp;squareEight, char &amp;squareNine)
  {
  
      cout &lt;&lt; squareOne &lt;&lt; "|" &lt;&lt; squareTwo &lt;&lt; "|" &lt;&lt; squareThree &lt;&lt; endl
              &lt;&lt; "-+-+-"&lt;&lt; endl
              &lt;&lt; squareFour &lt;&lt; "|" &lt;&lt; squareFive &lt;&lt; "|" &lt;&lt; squareSix &lt;&lt; endl
              &lt;&lt; "-+-+-"&lt;&lt; endl
              &lt;&lt; squareSeven &lt;&lt; "|" &lt;&lt; squareEight &lt;&lt; "|" &lt;&lt; squareNine &lt;&lt; endl;
  </code></pre>
  
  <p>The problem I am having is taking this code and turning it to the a function.
  Listed below is the code of what I am trying to make into a function. Followed after it the "checkboard" function is me trying to make the code above it into a function</p>
  
  <pre><code>  bGameOver     = false;
                  bool bWinGame   = true;
                  // Check for end of game conditions
                  if (squareOne != '1') {
                      if (squareTwo == squareOne &amp;&amp; squareThree == squareOne) {
                          bGameOver = true;
                      }
                      if (squareFour == squareOne &amp;&amp; squareSeven == squareOne) {
                          bGameOver = true;
                      }
                  }
                  if (squareFive != '5') 
                  {
                      if (squareOne == squareFive &amp;&amp; squareNine == squareFive) 
                      {
                          bGameOver = true;
                      }
                      if (squareTwo == squareFive &amp;&amp; squareEight == squareFive) 
                      {
                          bGameOver = true;
                      }
                      if (squareFour == squareFive &amp;&amp; squareSix == squareFive) 
                      {
                          bGameOver = true;
                      }
                      if (squareThree == squareFive &amp;&amp; squareSeven == squareFive) 
                      {
                          bGameOver = true;
                      }
                  }
                  if (squareNine != '9') 
                  {
                      if (squareThree == squareNine &amp;&amp; squareSix == squareNine) 
                      {
                          bGameOver = true;
                      }
                      if (squareSeven == squareNine &amp;&amp; squareEight == squareNine) 
                      {
                          bGameOver = true;
                      }
                  }
                  /* Need to check the board full (no-win condition*/)
                  if (squareOne != '1' &amp;&amp; squareTwo != '2' &amp;&amp; squareThree != '3' &amp;&amp;
                      squareFour != '4' &amp;&amp; squareFive != '5' &amp;&amp; squareSix != '6' &amp;&amp;
                      squareSeven != '7' &amp;&amp; squareEight != '8' &amp;&amp; squareNine != '9' &amp;&amp; !bGameOver)
                  {
                      bGameOver = true;
                      bWinGame = false;
                  }
  
                  system("cls");
  
                  if (bGameOver) 
                  {
                      if (bWinGame) 
                      {
                          cout &lt;&lt; "Player " &lt;&lt; currentPlayer &lt;&lt; " wins!" &lt;&lt; endl;
                      }
                      // Print ending board
                      cout &lt;&lt; squareOne &lt;&lt; "|" &lt;&lt; squareTwo &lt;&lt; "|" &lt;&lt; squareThree &lt;&lt; endl;
                      cout &lt;&lt; "-+-+-"&lt;&lt; endl;
                      cout &lt;&lt; squareFour &lt;&lt; "|" &lt;&lt; squareFive &lt;&lt; "|" &lt;&lt; squareSix &lt;&lt; endl;
                      cout &lt;&lt; "-+-+-"&lt;&lt; endl;
                      cout &lt;&lt; squareSeven &lt;&lt; "|" &lt;&lt; squareEight &lt;&lt; "|" &lt;&lt; squareNine &lt;&lt; endl;
  
                      cout &lt;&lt; "Game Over!" &lt;&lt; endl;
                      cout &lt;&lt; "Play again (y/n)?" &lt;&lt; endl;
                      char cPlayAgain;
                      cin &gt;&gt; cPlayAgain;
  
                      if (cPlayAgain == 'y') 
                      {
                          bGameOver = false;
                          /* Clear the board*/
                          squareOne = '1';
                          squareTwo = '2';
                          squareThree = '3';
                          squareFour = '4';
                          squareFive = '5';
                          squareSix = '6';
                          squareSeven = '7';
                          squareEight = '8';
                          squareNine = '9';
                      }
                      currentPlayer[100] = 1;
                  } 
  
              } while (!bGameOver);
  
  
  
  void checkboard(char** pCurrentPlayer, char &amp;squareOne, char &amp;squareTwo, char &amp;squareThree, char &amp;squareFour, char &amp;squareFive, char &amp;squareSix, char &amp;squareSeven,
                      char &amp;squareEight, char &amp;squareNine, char &amp;playerMarker, bool bGameOver)
      {
  
              bGameOver       = false;
              bool bWinGame   = true;
              // Check for end of game conditions
              if (squareOne != '1') {
                  if (squareTwo == squareOne &amp;&amp; squareThree == squareOne) {
                      bGameOver = true;
                  }
                  if (squareFour == squareOne &amp;&amp; squareSeven == squareOne) {
                      bGameOver = true;
                  }
              }
              if (squareFive != '5') 
              {
                  if (squareOne == squareFive &amp;&amp; squareNine == squareFive) 
                  {
                      bGameOver = true;
                  }
                  if (squareTwo == squareFive &amp;&amp; squareEight == squareFive) 
                  {
                      bGameOver = true;
                  }
                  if (squareFour == squareFive &amp;&amp; squareSix == squareFive) 
                  {
                      bGameOver = true;
                  }
                  if (squareThree == squareFive &amp;&amp; squareSeven == squareFive) 
                  {
                      bGameOver = true;
                  }
              }
              if (squareNine != '9') 
              {
                  if (squareThree == squareNine &amp;&amp; squareSix == squareNine) 
                  {
                      bGameOver = true;
                  }
                  if (squareSeven == squareNine &amp;&amp; squareEight == squareNine) 
                  {
                      bGameOver = true;
                  }
              }
              // Need to check the board full (no-win condition)
              if (squareOne != '1' &amp;&amp; squareTwo != '2' &amp;&amp; squareThree != '3' &amp;&amp;
                  squareFour != '4' &amp;&amp; squareFive != '5' &amp;&amp; squareSix != '6' &amp;&amp;
                  squareSeven != '7' &amp;&amp; squareEight != '8' &amp;&amp; squareNine != '9' &amp;&amp; !bGameOver)
              {
                  bGameOver = true;
                  bWinGame = false;
              }
  
              system("cls");
  
              if (bGameOver) 
              {
                  if (bWinGame) 
                  {
                      cout &lt;&lt; "Player " &lt;&lt; pCurrentPlayer &lt;&lt; " wins!" &lt;&lt; endl;
                  }
                  // Print ending board
                  cout &lt;&lt; squareOne &lt;&lt; "|" &lt;&lt; squareTwo &lt;&lt; "|" &lt;&lt; squareThree &lt;&lt; endl;
                  cout &lt;&lt; "-+-+-"&lt;&lt; endl;
                  cout &lt;&lt; squareFour &lt;&lt; "|" &lt;&lt; squareFive &lt;&lt; "|" &lt;&lt; squareSix &lt;&lt; endl;
                  cout &lt;&lt; "-+-+-"&lt;&lt; endl;
                  cout &lt;&lt; squareSeven &lt;&lt; "|" &lt;&lt; squareEight &lt;&lt; "|" &lt;&lt; squareNine &lt;&lt; endl;
  
                  cout &lt;&lt; "Game Over!" &lt;&lt; endl;
                  cout &lt;&lt; "Play again (y/n)?" &lt;&lt; endl;
                  char cPlayAgain;
                  cin &gt;&gt; cPlayAgain;
  
                  if (cPlayAgain == 'y') 
                  {
                      bGameOver = false;
                      // Clear the board
                      squareOne = '1';
                      squareTwo = '2';
                      squareThree = '3';
                      squareFour = '4';
                      squareFive = '5';
                      squareSix = '6';
                      squareSeven = '7';
                      squareEight = '8';
                      squareNine = '9';
                  }
                  pCurrentPlayer = "1";
              } 
  
      } 
  </code></pre>