title: Allocating a large array on the stack in C
body: <p>I have the following program:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;sys/resource.h&gt;
  
  int main()
  {
  
      // Anything over ~8MB fails
      short int big[4000000];
      printf("%lu\n", sizeof(big));
  
  }
  </code></pre>
  
  <p><code>ulimit</code> shows that I have unlimited memory available to the program. However, if I try and allocate more memory I get an error:</p>
  
  <pre><code>short int big[6000000];
  $ gcc main.c -o main.out &amp;&amp; ./main.out
  Segmentation fault: 11
  </code></pre>
  
  <p>Is there anything I need to change within the C program so that I can allocate, for example a 1GB array?</p>