title: C++ new & delete and string & functions
body: <p>Okay the <a href="https://stackoverflow.com/questions/2965927/c-new-delete-and-functions">previous</a> question was answered clearly, but i found out another problem.</p>
  
  <p>What if I do:</p>
  
  <pre><code>char *test(int ran){ 
      char *ret = new char[ran]; 
      // process... 
      return ret; 
  } 
  </code></pre>
  
  <p>And then run it:</p>
  
  <pre><code>for(int i = 0; i &lt; 100000000; i++){ 
     string str = test(rand()%10000000+10000000); 
     // process... 
  
     // no need to delete str anymore? string destructor does it for me here?
  } 
  </code></pre>
  
  <p>So after converting the char* to string, I don't have to worry about the deleting anymore?</p>
  
  <p><strong>Edit:</strong> As answered, I have to <code>delete[]</code> each <code>new[]</code> call, but on my case its not possible since the pointer got lost, so the question is: how do I convert char to string properly?</p>