title: Programming tictactoe in C with specifications
body: <p>Im working on a project for my intro to C programming class and most of it I have been able to do, but just looking for some advice on how to reach the last couple steps since I've hit a wall. 
  1) It is a Tic Tac Toe program designed for two users to manually play, using their names. 
  2) This code must be modularized (at least for the game board and check winner functions)
  3) Once a winner is declared, it should prompt the user if they would like to play again
  4) If playing again, it must start with a new game board and keep track of games played and count the amount of times each player won.</p>
  
  <p>So far my code is functional to take in and use players names, play the game itself, and check for a winner. The part I'm stuck at is figuring how to prompt to play again, and do that while counting and displaying the games played and the amount of times won for each player. </p>
  
  <p>Any help and suggestions would be great! Thanks!</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;stdbool.h&gt;
  
  // Prototypes
  int check_winner(char game_score[9], char player1[10], char player2[10]);
  char game_board(char game_score[9]);
  
  // Begin main
  int main(void)
  {
  // Initialize ad declare variables
  char player1[10], player2[10];
  char game_score[9] = {'1','2','3','4','5','6','7','8','9'};
  int go, game_count, player1_wins, player2_wins;
  int i, turn, play_again;
  
  printf("\nWelcome to Tic-Tac-Toe!!\n\nWhat is Player 1's name? You will be X's: ");
  fgets(player1, 10, stdin);
  
  printf("\nWhat is Player 2's name? You will be O's: ");
  fgets(player2, 10, stdin);
  
  // Begin game that last 9 turns
  for (turn = 1 ; turn &lt;= 9 ; turn++)
  {
      // Display the initial game board
      game_board(game_score);
  
      // Prompt the first player to select where to go
      printf("\n\n%s\nit is your turn! Please select the number where\n", player1);
      printf("you want to place your X: ");
      scanf("%d", &amp;go);
  
      // Place X in the selected spot on the board
      game_score[go-1] = 'X';
  
      // Check for a winner
      check_winner(game_score, player1, player2);
  
      // Display the game board updated with Player 1's move
      game_board(game_score);
  
      // Prompt Player 2 to select where to go
      printf("\n\n%s\nit is your turn! Please select the number where\n", player2);
      printf("you want to place your O: ");
      scanf("%d", &amp;go);
  
      // Place O in selected spot on the board
      game_score[go-1] = 'O';
  
      // Check for a winner
      check_winner(game_score, player1, player2);
  }
  
  
  
  return 0;
  }
  
  // Check winner function
  int check_winner(char game_score[9], char player1[10], char player2[10])
  {
  int i;
  
  if (game_score[0] == 'X' &amp;&amp; game_score[3] == 'X' &amp;&amp; game_score[6] == 'X')
      printf("\n\n%syou are the winner! Would you like to play again?: ", player1);
      else if (game_score[1] == 'X' &amp;&amp; game_score[4] == 'X' &amp;&amp; game_score[7] == 'X')
          printf("\n\n%syou are the winner! Would you like to play again?: ", player1);
      else if (game_score[2] == 'X' &amp;&amp; game_score[5] == 'X' &amp;&amp; game_score[8] == 'X')
          printf("\n\n%syou are the winner! Would you like to play again?: ", player1);
      else if (game_score[0] == 'X' &amp;&amp; game_score[1] == 'X' &amp;&amp; game_score[2] == 'X')
          printf("\n\n%syou are the winner! Would you like to play again?: ", player1);
      else if (game_score[3] == 'X' &amp;&amp; game_score[4] == 'X' &amp;&amp; game_score[5] == 'X')
          printf("\n\n%syou are the winner! Would you like to play again?: ", player1);
      else if (game_score[6] == 'X' &amp;&amp; game_score[7] == 'X' &amp;&amp; game_score[8] == 'X')
          printf("\n\n%syou are the winner! Would you like to play again?: ", player1);
      else if (game_score[0] == 'X' &amp;&amp; game_score[4] == 'X' &amp;&amp; game_score[8] == 'X')
          printf("\n\n%syou are the winner! Would you like to play again?: ", player1);
      else if (game_score[2] == 'X' &amp;&amp; game_score[4] == 'X' &amp;&amp; game_score[6] == 'X')
          printf("\n\n%syou are the winner! Would you like to play again?: ", player1);
  
      else if (game_score[0] == 'O' &amp;&amp; game_score[3] == 'O' &amp;&amp; game_score[6] == 'O')
          printf("\n\n%syou are the winner! Would you like to play again?: ", player2);
      else if (game_score[1] == 'O' &amp;&amp; game_score[4] == 'O' &amp;&amp; game_score[7] == 'O')
          printf("\n\n%syou are the winner! Would you like to play again?: ", player2);
      else if (game_score[2] == 'O' &amp;&amp; game_score[5] == 'O' &amp;&amp; game_score[8] == 'O')
          printf("\n\n%syou are the winner! Would you like to play again?: ", player2);
      else if (game_score[0] == 'O' &amp;&amp; game_score[1] == 'O' &amp;&amp; game_score[2] == 'O')
          printf("\n\n%syou are the winner! Would you like to play again?: ", player2);
      else if (game_score[3] == 'O' &amp;&amp; game_score[4] == 'O' &amp;&amp; game_score[5] == 'O')
          printf("\n\n%syou are the winner! Would you like to play again?: ", player2);
      else if (game_score[6] == 'O' &amp;&amp; game_score[7] == 'O' &amp;&amp; game_score[8] == 'O')
          printf("\n\n%syou are the winner! Would you like to play again?: ", player2);
      else if (game_score[0] == 'O' &amp;&amp; game_score[4] == 'O' &amp;&amp; game_score[8] == 'O')
          printf("\n\n%syou are the winner! Would you like to play again?: ", player2);
      else if (game_score[2] == 'O' &amp;&amp; game_score[4] == 'O' &amp;&amp; game_score[6] == 'O')
          printf("\n\n%syou are the winner! Would you like to play again?: ", player2);
  
  }
  
  // Game board display function
  char game_board(char game_score[9])
  {
  
  printf("\n\n %c | %c | %c \n---+---+---\n %c | %c | %c \n---+---+---\n %c | %c | %c \n",
         game_score[0], game_score[1], game_score[2], game_score[3], game_score[4],
         game_score[5], game_score[6], game_score[7], game_score[8]);
  return 0;
  }
  </code></pre>