title: Why this C++ program should crash runtime?
body: <p>I am newbie in C++ and I am trying to write a program in C++. Below is my code. When it comes to the lines indicated by comment <code>//PROGRAM crashes</code> ,  the program crashes and gives this error: <code>Process returned -1073741819 (0xC0000005)</code>. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cmath&gt;
  #include &lt;fstream&gt;
  #include &lt;cassert&gt;
  
  using namespace std;
  
  int main (int argc, char* argv[])
  {
      double simTime = 5;
      double r = 0.9;
      double t, F = 1;
      int i, counter = 0;
      int n = 100;
  
      double* u_n = new double[n];
      double* u_n_minus_one = new double[n];
      double* u_n_plus_one = new double[n];
  
      for (i=0;i&lt;n;i++)
      {
          u_n[i]=0;
          u_n_minus_one[i]=0;
          u_n_plus_one[i]=0;
      }
  
      std::ofstream fw1("Values.txt");
      assert(fw1.is_open());
  
      for (t = 0; t &lt;= simTime; t = t + 0.5)
      {
          for (i = 1; i &lt;= (n-2); i++)
          {
              u_n_plus_one[i] =  pow(r, 2) * (u_n[i-1] + u_n[i+1]) + 2 * (1 - pow(r, 2)) * u_n[i] -u_n_minus_one[i];
          }
  
          u_n_plus_one[0] = 0;
          u_n_plus_one[int(floor((n)/2))] = F;
          u_n_plus_one[n-1] = 0;
  
          for (i=0;i&lt;n;i++)
          {
              u_n_minus_one[i] = u_n[i];
          }
  
          for (i=0;i&lt;n;i++)
          {
              u_n[i] = u_n_plus_one[i];
          }
  
          fw1.precision(6);
  
          //PROGRAM crashes here.
          for (i=0; i&lt;n; i++)
          {
              fw1 &lt;&lt; u_n_plus_one[i] &lt;&lt; '\t';
          }
  
          fw1 &lt;&lt; std::endl;
  
          fw1.close();
  
          delete[] u_n; delete[] u_n_plus_one; delete[] u_n_minus_one;
      }
  }
  </code></pre>
  
  <p>I found this crash location with Code::Blocks debugger. Basically, when I try to  I tried debugging further, that is to get the contents of array <code>u_n_plus_one</code>, program crashes. 
  Code::Blocks debugger does not seem to give contents of array. I have following specific questions associated with this program.</p>
  
  <ol>
  <li>What exactly is causing failure and how to debug this?</li>
  <li>If I want to get contents of array in Code::Blocks, can I get that? That means, if an array has only 4 elements, can I get list of all 4 or if an array has 1000 elements, can I get just element at 50th location?</li>
  <li>Can I do variable manipulations in debugger? I mean, in MATLAB if I am debugging, I can enter a command in command window, say A+B and get result. Is it possible with C++?</li>
  </ol>
  
  <p>I would highly appreciate any help.</p>