title: How to let player chose to be X or O as well as an option to play the game again?
body: <p>So I need some help in this Tic-Tac-Toe game. I have almost everything working correctly I just need to add on some features. Those features include: 1.) allowing the player to choose whether they want to play as X or O in the game, and 2.) giving the option for the players to replay the game if they wish. I've gotten the base mechanics of the game to work out nicely, I just can't figure out how to add these features into the code. I've started to &quot;lay the foundation&quot; for the first feature (giving the player the option to choose their mark). (Honestly, I'm just really tired from studying for the past 48hrs for finals and I could really use a helping hand here). Here is my full code:</p>
  <pre><code>#define _CRT_SECURE_NO_WARNINGS
  #pragma warning(disable : 4996)
  #include &lt;stdio.h&gt;
   #include &lt;conio.h&gt;
  
  
  int checkwin(char gridspace[]);
  void gameboard(char gridspace[]);
  int gameLoop(int choice, int player, char gridspace[], char mark);
  
  void main(void)
  {
  char grid[10] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
  int player = 1, victory, choice;
  
  char mark, player1, player2;
  int markchoice;
  do // game loop start
  {
      gameboard(grid); // draws the game board
      if (player % 2) // player turn conditional
      {
          player = 1;
      }
      else
      {
          player = 2;
      }
      printf(&quot;Player 1, choose which mark you would like to play as (1=X or 2=O)\n&quot;); // asks the player to choose a mark
      scanf(&quot;%c&quot;, &amp;markchoice);
      if (markchoice == 1) // mark choice conditional
      {
          mark = 'X';            
      }
      else
      {
          mark = 'O';             
      }
      printf(&quot;Player %d, enter the number of the place you wish to place your mark:  &quot;, player); // asks the player to place their mark on a space
      scanf(&quot;%d&quot;, &amp;choice);
      if (player == 1) // mark type (X or O) placement conditional 
      {
          mark;
      }
      else
      {
          mark;
      }
      gameLoop(choice, player, grid, mark); // calls the main game function that houses the conditionals 
      
      victory = checkwin(grid); // checks the state of the game (if its in progress, a draw, or a player has achieved victory.
  
      player++;
  } while (victory == -1); //end of game loop
  
  gameboard(grid); // redraws the game board
  
  if (victory == 1) // conditional that breaks the game loop and gives a result (victory or draw)
  {
      printf(&quot;==&gt;\aPlayer %d win &quot;, --player);
  }
  else 
  {
      printf(&quot;==&gt;\aGame draw&quot;);
      getch();
  }
  return 0; 
  } // end of main
  int gameLoop(int choice,int player, char gridspace[], char mark) // function for game loop 
  decisionals
  {
  if (choice == 1 &amp;&amp; gridspace[1] == '1')
      gridspace[1] = mark;
  
  else if (choice == 2 &amp;&amp; gridspace[2] == '2')
      gridspace[2] = mark;
  
  else if (choice == 3 &amp;&amp; gridspace[3] == '3')
      gridspace[3] = mark;
  
  else if (choice == 4 &amp;&amp; gridspace[4] == '4')
      gridspace[4] = mark;
  
  else if (choice == 5 &amp;&amp; gridspace[5] == '5')
      gridspace[5] = mark;
  
  else if (choice == 6 &amp;&amp; gridspace[6] == '6')
      gridspace[6] = mark;
  
  else if (choice == 7 &amp;&amp; gridspace[7] == '7')
      gridspace[7] = mark;
  
  else if (choice == 8 &amp;&amp; gridspace[8] == '8')
      gridspace[8] = mark;
  
  else if (choice == 9 &amp;&amp; gridspace[9] == '9')
      gridspace[9] = mark;
  
  else
  {
      printf(&quot;Invalid move, input a different number.&quot;);
  
      player--;
      getch();
  }
  return 1;
  }// end of game loop function
  
  int checkwin(char gridspace[]) // check win function 
  {
  if (gridspace[1] == gridspace[2] &amp;&amp; gridspace[2] == gridspace[3])
      return 1;
  
  else if (gridspace[4] == gridspace[5] &amp;&amp; gridspace[5] == gridspace[6])
      return 1;
  
  else if (gridspace[7] == gridspace[8] &amp;&amp; gridspace[8] == gridspace[9])
      return 1;
  
  else if (gridspace[1] == gridspace[4] &amp;&amp; gridspace[4] == gridspace[7])
      return 1;
  
  else if (gridspace[2] == gridspace[5] &amp;&amp; gridspace[5] == gridspace[8])
      return 1;
  
  else if (gridspace[3] == gridspace[6] &amp;&amp; gridspace[6] == gridspace[9])
      return 1;
  
  else if (gridspace[1] == gridspace[5] &amp;&amp; gridspace[5] == gridspace[9])
      return 1;
  
  else if (gridspace[3] == gridspace[5] &amp;&amp; gridspace[5] == gridspace[7])
      return 1;
  
  else if (gridspace[1] != '1' &amp;&amp; gridspace[2] != '2' &amp;&amp; gridspace[3] != '3' &amp;&amp; 
      gridspace[4] != '4' &amp;&amp; gridspace[5] != '5' &amp;&amp; gridspace[6] != '6' &amp;&amp; gridspace[7]
      != '7' &amp;&amp; gridspace[8] != '8' &amp;&amp; gridspace[9] != '9') // if all spaces are filled but no 
  three match then the game is a draw
  
      return 0;
  else // if no three spaces match and empty spaces still exist then the game is still in 
  progress. 
      return  -1;
  } // end of check win function
  
  void gameboard(char gridspace[]) // game board function.
  {
  system(&quot;cls&quot;);
  printf(&quot;\n\n\tTic Tac Toe\n\n&quot;);
  printf(&quot;Enter a number for where you wish to place your mark&quot;);
  printf(&quot;Player 1 (X)  -  Player 2 (O)\n\n\n&quot;);
  
  
  printf(&quot;     |     |     \n&quot;);
  printf(&quot;  %c  |  %c  |  %c \n&quot;, gridspace[1], gridspace[2], gridspace[3]);
  
  printf(&quot;_____|_____|_____\n&quot;);
  printf(&quot;     |     |     \n&quot;);
  
  printf(&quot;  %c  |  %c  |  %c \n&quot;, gridspace[4], gridspace[5], gridspace[6]);
  
  printf(&quot;_____|_____|_____\n&quot;);
  printf(&quot;     |     |     \n&quot;);
  
  printf(&quot;  %c  |  %c  |  %c \n&quot;, gridspace[7], gridspace[8], gridspace[9]);
  
  printf(&quot;     |     |     \n\n&quot;);
  } // end of board drawing funciton.
  </code></pre>
  <p>Any and all help would be greatly appreciated. So thank you in advance!</p>