title: wrong memory allocation new char [n]
body: <p>What is wrong with this program?</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  void main()
  {
  
      int n = 5;
      char* p = new char [n];
      int i;
      for(i=0;i&lt;n;i++)
      {
          p[i] = 'A'+i;
      }
      cout&lt;&lt;p&lt;&lt;endl;
  }
  </code></pre>
  
  <p>Why do I get "ABCDExxxx" instead of "ABCDE" ?
  What is wrong with memory allocation?</p>