title: Converting std::string from const_iterator to char*?
body: <p>I have an iterator of type:</p>
  
  <pre><code>std::map&lt;int, std::string&gt;::const_iterator
  </code></pre>
  
  <p>and as you can see the map is storing <code>std::strings</code>. </p>
  
  <p>I am trying to extract a value using:</p>
  
  <pre><code>x.second.c_str()
  </code></pre>
  
  <p>and pass it to a function to call the regex.h function regexec(), which accepts a <code>char*</code>. What is the best way to do this? I am getting <code>basic_string</code> compilation errors from this approach.</p>
  
  <p>Update:</p>
  
  <pre><code>std::map&lt;int, std::string&gt; map;
  .
  .
  .
  std::map&lt;int, std::string&gt;::const_iterator f = map.find("something");
  if (f != map.end()) {
      my_func(f-&gt;second.c_str());   
  .
  .
  .
  .
  
  void my_func(char* c){
      std::cout &lt;&lt; c &lt;&lt; std::endl;   //This causes a segmentation fault
  }
  </code></pre>