title: Why can't I create an array with size determined by a global variable?
body: <p>Why does the array <code>a</code> not get initialized by global variable <code>size</code>?</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int size = 5;
  
  int main()
  {
      int a[size] = {1, 2, 3, 4, 5};
      printf("%d", a[0]);
  
      return 0;
  }
  </code></pre>
  
  <p>The compilation error is shown as </p>
  
  <blockquote>
    <p>variable-sized object may not be initialized</p>
  </blockquote>
  
  <p>According to me, the array should get initialized by <code>size</code>.</p>
  
  <p>And what would be the answer if I insist on using global variable (if it is possible)?</p>