title: Does deleting dynamically allocated std::string using a pointer returned by c_str() cause a memory leak in C++?
body: <p>I'm writing a function to load a txt file and return a const char* 
  the function below works, my question is will this function cause a memory leak if I don't store *pS and then call delete pS ?</p>
  
  <pre><code>const char* loadFile(string fname)
  {
     string line,text;
     ifstream in(fname);
     while(std::getline(in, line))
     {
         text += line + "\n";
     }
  
     string *pS = new string(text);
     const char* data = pS-&gt;c_str();
  
     return data;
  }
  </code></pre>
  
  <p>the function is used in my code as follows </p>
  
  <pre><code>static const char* pVS;
  ...
  pVS = loadFile("VS.txt");
  ...
  delete pVS;
  </code></pre>
  
  <p>Will this delete the string ?</p>