title: semi-dynamic allocation code work in c++, but not in c, why?
body: <p>below two codes works fine in c++ file, but compile error in c, why?
  it seems to use const variable causing some problem in c,
  i use dev c++ 5.11</p>
  <blockquote>
  <p>19 3   C:\Users\tjc\Desktop\c練習\Untitled4.c    [Error] variable-sized object may not be initialized</p>
  <p>19 3   C:\Users\tjc\Desktop\c練習\Untitled4.c    [Warning] excess elements in array initializer</p>
  <p>19 3   C:\Users\tjc\Desktop\c練習\Untitled4.c    [Warning] (near initialization for 'A')</p>
  </blockquote>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;memory.h&gt;
  int cmpW( const void* p1, const void*p2){
       float *pf1 = (float*)p1;
       float *pf2 = (float*)p2;
       return pf1[0] - pf2[0];
  }
  int cmpH( const void* p1, const void*p2){
       float *pf1 = (float*)p1;
       float *pf2 = (float*)p2;
       return pf2[1] - pf1[1];
  }
  
  int main(void)
  {
       const size_t n = 5;
       float A[n][2] = {0}; //line 19
       int i=0;
       for(i=0; i&lt;n; ++i){ // Data input.
       printf(&quot;W H: &quot;);
       scanf(&quot;%f %f&quot;, &amp;A[i][0], &amp;A[i][1]);
       }
       qsort(A, n, sizeof(float) * 2, cmpW ); // By weight
       for(i=0; i&lt;n; ++i) // Data input.
       printf(&quot;(%f, %f) &quot;, A[i][0], A[i][1]);
       printf(&quot;\n&quot;);
       qsort(A, n, sizeof(float) * 2, cmpH ); // By height
       for(i=0; i&lt;n; ++i) // Data input.
       printf(&quot;(%f, %f) &quot;, A[i][0], A[i][1]);
       printf(&quot;\n&quot;);
       
      system(&quot;pause&quot;);
  }
  </code></pre>