title: How to return a std::string.c_str()
body: <p>I have a method which returns the constant char pointer. It makes use of a <code>std::string</code> and finally returns its <code>c_str()</code> char pointer.</p>
  
  <pre><code>const char * returnCharPtr()
  {
      std::string someString;
  
      // some processing!.
  
      return someString.c_str();
  }
  </code></pre>
  
  <p>I have got a report from COVERITY tool that the above is not a good usage. I have googled and have found that the char pointer returned, would be invalidated as soon as <code>someString</code> meets its destruction.</p>
  
  <p>Given this, how does one fix this issue? How to return char pointer accurately?</p>
  
  <p>Returning <code>std::string</code> would resolve this issue. But I want to know if there is any other means of doing this.</p>