How to convert std::string to const char*?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/347949/convert-stdstring-to-const-char-or-char">Convert std::string to const char* or char*</a>  </p>
</blockquote>



<pre><code>void Foo::bar(const std::string&amp; foobar) {
    // ...
    const char* foobar2 = (char*)foobar;
    // ...
}
</code></pre>

<p>That does not work and I get an error during compilation about invalid casting.</p>

<p>Is there some other way to convert <code>std::string</code> to <code>const char*</code>?</p>
