title: I´m making a simple tic-tac-toe game in C and it ends after the first input
body: <p>I have this problem and I don´t know what´s wrong. The code doesn´t have any errors or warnings but it always take the first <code>if</code> statement of the checkVictory function as correct.</p>
  <p>I've tried comparing my code with another one that actually works and it looks identical to me. I´m pretty sure the mistake is in the checkVictory function because I used a variable called flag to check every if statement of the function and my returnValue (which is used as an indicator of my game status) always get triggered by the first if.</p>
  <p>Here´s my code... (sorry for the indentation this is my first time using the website)</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;conio.h&gt;
  
  void board();
  void markBoard(char mark);
  int checkVictory();
  
  int player, choice, flag;
  char list[10] = {'-', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
  
  void main() {
      int gameStatus;
      char mark;
      player = 1;
  
      do{
          board();
  
          // change turns
          player = (player % 2) ? 1 : 2;
  
          //input
          printf(&quot;Player %d, enter a number: &quot;, player);
          scanf(&quot;%i&quot;, &amp;choice);
  
          // set the correct character based on player turn
          mark = (player == 1) ? 'X' : 'O';
  
          markBoard(mark);
      
          gameStatus = checkVictory();
      
          player++; 
      } while (gameStatus == -1);
  
      if (gameStatus == 1) {
          printf(&quot;Player %d WIN&quot;, --player);
          printf(&quot;\nflag: %i&quot;, flag);
      }
      else{
          printf(&quot;Draw&quot;);
      }
  }
  
  void board() {
      system(&quot;cls&quot;); 
      printf(&quot;\n\n\t   tic tac toe\n\n&quot;);
      printf(&quot;Player 1 (X)    -    Player 2 (O)\n\n&quot;);
  
      printf(&quot;     |     |     \n&quot;);
      printf(&quot;  %c  |  %c  |  %c  \n&quot;, list[1], list[2], list[3]);
      printf(&quot;_____|_____|_____\n&quot;);
      printf(&quot;     |     |     \n&quot;);
      printf(&quot;  %c  |  %c  |  %c  \n&quot;, list[4], list[5], list[6]);
      printf(&quot;_____|_____|_____\n&quot;);
      printf(&quot;     |     |     \n&quot;);
      printf(&quot;  %c  |  %c  |  %c  \n&quot;, list[7], list[8], list[9]);
      printf(&quot;     |     |     \n&quot;);
  
      printf(&quot;\n&quot;);
  }
  
  void markBoard(char mark) {
      if (choice == 1 &amp;&amp; list[1] == '1')
          list[1] = mark;
      else if (choice == 2 &amp;&amp; list[2] == '2')
          list[2] = mark;
      else if (choice == 3 &amp;&amp; list[3] == '3')
          list[3] = mark;
      else if (choice == 4 &amp;&amp; list[4] == '4')
          list[4] = mark;
      else if (choice == 5 &amp;&amp; list[5] == '5')
          list[5] = mark;
      else if (choice == 6 &amp;&amp; list[6] == '6')
          list[6] = mark;
      else if (choice == 7 &amp;&amp; list[7] == '7')
          list[7] = mark;
      else if (choice == 8 &amp;&amp; list[8] == '8')
          list[8] = mark;
      else if (choice == 9 &amp;&amp; list[9] == '9')
          list[9] = mark;
      else {
          printf(&quot;Invalid move\n&quot;);
          player--;
          getch();
      }
  }
  
  /*********************************************FUNCTION TO RETURN GAME STATUS1 FOR GAME IS OVER WITH RESULT-1 FOR GAME IS IN PROGRESSO GAME IS OVER AND NO RESULT**********************************************/
  
  int checkVictory() {
      int returnValue = 0;
  
      if (list[1] &amp;&amp; list[2] == list[2] &amp;&amp; list[3]) {
          returnValue = 1;
          flag = 1;
      }
      else if (list[4] &amp;&amp; list[5] == list[5] &amp;&amp; list[6]) {
          returnValue = 1;
          flag = 2;
      }
      else if (list[7] &amp;&amp; list[8] == list[8] &amp;&amp; list[9]) {
          returnValue = 1;
          flag = 3;
      }
      else if (list[1] &amp;&amp; list[4] == list[4] &amp;&amp; list[7]) {
          returnValue = 1;
          flag = 4;
      }
      else if (list[2] &amp;&amp; list[5] == list[5] &amp;&amp; list[8]) {
          returnValue = 1;
          flag = 5;
      }
      else if (list[3] &amp;&amp; list[6] == list[6] &amp;&amp; list[9]) {
          returnValue = 1;
          flag = 6;
      }
      else if (list[1] &amp;&amp; list[5] == list[5] &amp;&amp; list[9]) {
          returnValue = 1;
          flag = 7;
      }
      else if (list[3] &amp;&amp; list[5] == list[5] &amp;&amp; list[7]) {
          returnValue = 1;
          flag = 8;
      }
      else if (list[1] != '1' &amp;&amp; list[2] != '2' &amp;&amp; list[3] != '3' &amp;&amp;
               list[4] != '4' &amp;&amp; list[5] != '5' &amp;&amp; list[6] != '6' &amp;&amp; 
               list[7] != '7' &amp;&amp; list[8] != '8' &amp;&amp; list[9] != '9') {
          returnValue = 0;
      }
      else
          returnValue = -1;
  
      return returnValue;
  }
  </code></pre>