title: How to fill a 2D array in C with user input values?
body: <p>Note: This is a homework question.</p>
  
  <blockquote>
    <p>Use FOR construction to fill 2D board with values that were given by
    user. The program asks for board size n, m and then it asks for each
     board value.</p>
  </blockquote>
  
  <p>My try </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main(){
      printf("Enter the number of columns");
      int i = scanf("%d",&amp;i);
      printf("Enter the number of rows");
      int y = scanf("%d",&amp;y);
  
      int r[i][y];
      int a;
      int b;
      for (a=0; a&lt;i; a++){
          for(b=0; b&lt;y; b++){
              int r[a][b] = scanf("%d",&amp;a,&amp;b); //bug
          }
      }
  }
  </code></pre>
  
  <p><code>Bug: c:13 variable-sized object may not be initialized</code></p>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(){
  
      printf("Enter the number of columns");
      int i; 
      scanf("%d", &amp;i);
      printf("Enter the number of rows");
      int y; 
      scanf("%d", &amp;y);
  
      int r[i][y];
      int a;
      int b;
  
          for (a=0; a&lt;i; a++){
              for (b=0; b&lt;y; b++){
      scanf("%d",&amp;r[a][b]);
          }
      }
  }
  </code></pre>