title: C++ memory leaks: are dynamically created arrays removed on leaving a function call?
body: <p>So I have a function that creates a dynamic array, I then delete the array before I leave the function (as I thought I am supposed to), however I am getting a 'Heap Corruption Detected' warning in VS2008. If I remove the line that deallocates the memory everything works fine:</p>
  
  <pre><code>void myFunc()
  {
      char* c = new char[length];
      memset(c, 0, length);
  
      //.. do somsething with array
  
      delete[] c; //this line throws an error??
  }
  </code></pre>
  
  <p>Thanks for any advice</p>