title: Dynamic memory allocation for character arrays
body: <p>Okay, so I was trying to resize an array as follows : </p>
  
  <pre><code>if((editBufferCounter + 20) &gt; editBufferSize)
  {
      char* temp;
      temp = new char[editBufferSize + 5];
  
      strcpy(temp, editBuffer);
  
      delete[] editBuffer;
  
      editBufferSize *= 2;  
  
      editBuffer = new char[editBufferSize];
  
      strcpy(editBuffer, temp);
  
      delete[] temp;
  
  }
  </code></pre>
  
  <p>The last line <code>delete[] temp</code> causes a memory problem. The program simply crashes. I can't seem to get what the problem here is.</p>
  
  <p>Note:
  The program runs fine if i remove the line <code>delete[] temp;</code></p>