title: Getting a stack overflow exception when declaring a large array
body: <p>The following code is generating a stack overflow error for me</p>
  
  <pre><code>int main(int argc, char* argv[])
  {
      int sieve[2000000];
      return 0;
  }
  </code></pre>
  
  <p>How do I get around this? I am using Turbo C++ but would like to keep my code in C</p>
  
  <p>EDIT:</p>
  
  <p>Thanks for the advice.  The code above was only for example, I actually declare the array in a function and not in sub main.  Also, I needed the array to be initialized to zeros, so when I googled malloc, I discovered that calloc was perfect for my purposes.</p>
  
  <p>Malloc/calloc also has the advantage over allocating on the stack of allowing me to declare the size using a variable.</p>