title: converting std::string to char *
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/347949/convert-stdstring-to-const-char-or-char">Convert std::string to const char* or char*</a>  </p>
  </blockquote>
  
  
  
  <p>I have a <code>std::string</code> and want to pass that as a file name to fstream like</p>
  
  <pre><code>std::string fname = "/home/mahmood/filter" + boost::lexical_cast&lt;std::string&gt;(b) + ".txt";
  std::fstream fout (fname, std::fstream::app | std::fstream::out);
  </code></pre>
  
  <p>but I get an error for the second line</p>
  
  <pre><code>error: no matching function for call to ‘std::basic_fstream&lt;char, std::char_traits&lt;char&gt;   &gt;::basic_fstream(std::string&amp;, 
  </code></pre>
  
  <p>Seems that it can not convert <code>string</code> to <code>char *</code>. Also casting doesn't work</p>