title: How can i use the "edges" of a dynamic 2D array as a way to tell my program they are out of limit
body: <p>I will try my best to explain as well as i can what i mean and what my goal is, sorry if I'm failing to get my point through.</p>
  <p>Lets say i have this output when i run my code:</p>
  <pre><code>    1  2  3  4  5  6  7  8
     _________________________
  1 | .  .  .  $  .  .  .  .
  2 | .  .  .  .  .  .  #  .
  3 | .  #  .  .  .  .  .  .
  4 | .  .  .  .  4  .  .  .
  5 | .  .  .  .  .  .  .  .
  6 | 5  .  .  .  .  .  .  .
  7 | .  .  5  .  #  .  .  .
  8 | .  .  .  .  .  .  .  .
  </code></pre>
  <p>My code reads 2 dimensions given by the user and then using malloc it gives me this dynamic 2d array.
  The little '$' character is the player and the array is the level in which he is allowed to move, all my code that can &quot;move&quot; the player works perfectly fine, the player can collect the random numbers in the board which represent the value of a diamond he finds and if a user wants to move for example 4 spaces in a direction and at the 3d space there is the &quot;#&quot; symbol the character &quot;$&quot; stops and prints a message how many positions he moved before stopping in front of the obstacle. I want to achieve the exact same thing but with the edges of the board, for example in the output i am presenting above, &quot;$&quot; is sitting in the position [1][4] and if a user tries to move &quot;up&quot; in the board there is clearly no more  spaces to move so i want to show a message saying just that.</p>
  <p>This is the recursive function that gets called when the user wants to move up:</p>
  <pre><code>int Up(int **D_Board)
  {
      int column_pos, row_pos, stop;
      column_pos = Current_Position_Column(D_Board);
      row_pos = Current_Position_Row(D_Board);
      moving++;
      if (moving &lt;= moves)
      {
          if (D_Board[column_pos - 1][row_pos] == '.' || D_Board[column_pos - 1][row_pos] == ' ')
          {
              D_Board[column_pos][row_pos] = ' ';
              column_pos = column_pos - 1;
              D_Board[column_pos][row_pos] = '$';
              Up(D_Board);
          }
          else if (D_Board[column_pos - 1][row_pos] == '#')
          {
              D_Board[column_pos][row_pos] = '$';
              stop = moving - 1;
              moving = moves;
              printf(&quot;\nHit an obstacle...\n\nYou only moved %d positions.\n\n&quot;, stop);
          }
          if (D_Board[column_pos - 1][row_pos] &gt;= 0 &amp;&amp; D_Board[column_pos - 1][row_pos] &lt;= 9)
          {
              diamonds = diamonds + D_Board[column_pos - 1][row_pos];
              D_Board[column_pos][row_pos] = ' ';
              column_pos = column_pos - 1;
              D_Board[column_pos][row_pos] = '$';
          }
      }
      else
          return 0;
  }
  
  
  </code></pre>
  <p>If i add the conditions i use when it encounters &quot;#&quot; in the code but instead i define the top row as D_Board[0][row_pos] the code never enters that condition and exits my main loop that constantly asks the player to give inputs and i cant figure out why, i have tried some things without success for example:<code>if (column_pos == 0){do stuffs};</code> or <code>if(D_Board[column_pos-1][row_pos] == D_Board[0][row_pos]){do stuffs};</code></p>