title: C error "variable-sized object may not be initialized"
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3082914/c-compile-error-variable-sized-object-may-not-be-initialized">C compile error: “Variable-sized object may not be initialized”</a>  </p>
  </blockquote>
  
  
  
  <p>I've got a problem cause my compiler still gives me an error: Variable-sized object may not be initialized. What's wrong with my code?</p>
  
  <pre><code>int x, y, n, i;
  printf ("give me the width of the table \n");
  scanf ("%d", &amp;x);
  printf ("give me the height of the table\n");
  scanf ("%d", &amp;y);
  int plansza [x][y] = 0;
  int plansza2 [x][y] = 0;
  </code></pre>
  
  <p>Of course I want to fill the table with 'zeroes'.</p>
  
  <p>Unfortunately the program still doesn't work. The tables are displayed with numbers like '416082' on all of their cells. My code looks like this now.:</p>
  
  <pre><code>int plansza [x][y];
  memset(plansza, 0, sizeof plansza);
  int plansza2 [x][y];
  memset(plansza2, 0, sizeof plansza2);
  
  printf("plansza: \n");
  for(j=0;j&lt;x;j++) {
    for(l=0;l&lt;y;l++) {
      printf("%d",plansza[x][y]);
      printf(" ");
    }
    printf("\n");
  }
  
  printf("plansza2: \n");
  for(m=0;m&lt;x;m++) {
    for(o=0;o&lt;y;o++) {
      printf("%d",plansza2[x][y]);
      printf(" ");
    }
    printf("\n");
  }
  </code></pre>