title: Pointers in c++ and runtime errors
body: <p>What is the issue with this code? It gives the output as expected, but there is a runtime error, and I don't know what it is.</p>
  <p>Can somebody explain the concept behind it?</p>
  <pre><code>int main()
  {
      int *a = new int(7);//assume the heap memory has address 4F
      int *p;
      p = a;
      cout &lt;&lt; a &lt;&lt; endl;
      cout &lt;&lt; p &lt;&lt; endl;
      cout &lt;&lt; *a &lt;&lt; endl;
      cout &lt;&lt; *p &lt;&lt; endl;
      *p = 10;
      cout &lt;&lt; *a &lt;&lt; endl;
      delete p;
      delete a;
      return 0;
  }
  </code></pre>