title: C - Chomp questions
body: <p>I'm trying to create the game <a href="http://en.wikipedia.org/wiki/Chomp" rel="nofollow">Chomp</a>. I am halfway through but pretty stuck.</p>
  
  <p>The game will have 5 different functions. Pointers and structs are not allowed.</p>
  
  <p>a) <strong>initialize()</strong> Initialize every position in the matrix to 'O'. No parameters or return value.</p>
  
  <p>b) <strong>print_board()</strong> Prints the matrix. No parameters or return value.</p>
  
  <p>c) <strong>get_move()</strong> Scan a move from the player (row and col) and "return" it with an array. Parameters: Information about whos turn it is (Player 1 or Player 2), and an array with two elements where the move coordinates will be stored. No return value.</p>
  
  <p>d) <strong>check_move()</strong> Controls if a move is legal (not outside the matrix and not a position that has already been eaten). Parameters: The move that is going to be checked (row and col). Return value: Result of the control. &lt;------ ???????</p>
  
  <p>e) <strong>update_board()</strong> Updates the matrix. Parameters: The new move (row and col). No return value.</p>
  
  <p>This is how far I have come and I am stuck at the <strong>check_move()</strong> function. I don't understand what I am going to return from that function.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int height    =  4;
  int width     = 10;
  char matrix[4][10];
  
  
  void initialize()
  {
      for(int row = 0; row &lt; height; row++)
          for(int col = 0; col &lt; width; col++)
              matrix[row][col] = 'O';         
  }
  
  
  
  void print_board()
  {
      for(int row = 0; row &lt; height; row++)
      {
          for(int col = 0; col &lt; width; col++)
          {
              printf("%c", matrix[row][col]);
          }
          printf("\n");
      }   
      printf("\n");
  }
  
  
  
  void get_move(int player, int input[])
  {
      printf("Player %d, make your move: ", player);
      scanf("%d %d", &amp;input[0], &amp;input[1]);
  }
  
  
  
  int check_move(int position[])
  {
      int row = position[0];
      int col = position[1];
  
      if(row &lt;= height  &amp;&amp;  col &lt;= width)
      {
          for(row; row &lt;= height; row++)
          {
              for(col; col &lt;= width; col++)
              {
                  if(matrix[row][col] == ' ');
                  printf("Invalid move! \n");
              }
          }       
      }
  }
  
  
  
  void update_board(int x, int y)
  {
      for(int xi = x; xi &lt;= 10; ++xi)
      {
          for(int yi = y; yi &lt;= 10; ++yi)
              matrix[xi-1][yi-1] = ' ';
      }
  
  
  }
  
  
  
  int main(void)
  {
  
      int player = 1;
      int position[2]; 
  
      initialize();
      print_board();
  
      get_move(player, position);
  
      check_move(position);
  
      update_board(position[0], position[1]);
  
      print_board();
  
  
  
      getchar();
      getchar();
      getchar();
  
  
      return 0;
  }
  </code></pre>