title: Dev C++ Version 5.11 crashes prime sieve
body: <p>I've been trying to implement the Eratosthenes sieve in C++. I am using the Dev C++ 5.11 compiler and every time I run my code, the compiler <a href="http://i.stack.imgur.com/hyHQO.png" rel="nofollow">crashes</a>. For a smaller array value (n = 10000), the program runs successfully, but prints <a href="http://i.stack.imgur.com/1D1Tk.png" rel="nofollow">garbage values</a> in the text file (Please find image attached). I am an amateur in programming and have been working over this issue for over a day now. Would be glad for any help. 
  Thanks for your time! :) </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#include &lt;iostream&gt;
  using namespace std;
  #include &lt;fstream&gt;
  
  int main(){
   ofstream myfile("Prime.txt");
   int n = 1000000;
   int prime[n] = {0};
   for (int i = 2; i &lt;= n; i++){
     for (int j = i*i; j &lt;= n; j+=i){
      prime[j - 1] = 1;
     }
   }
   for (int i = 2; i &lt;= n; i++){
    //cout&lt;&lt;prime[i-1]&lt;&lt;endl;
    if (prime[i - 1] == 0)
     myfile&lt;&lt;i&lt;&lt;" ";
   }
   myfile.close();
   return 0;
  }</code></pre>
  </div>
  </div>
  </p>