title: Differences in use of c_str() when returning a value from a function
body: <p>If I have the following two functions</p>
  
  <pre><code>std::string foo1()
  {
      std::string temp;
      ...
      return temp;
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>const char* foo2()
  {
      std::string temp;
      ...
      return temp.c_str();
  }
  </code></pre>
  
  <p>and a function that takes a const char* as input;</p>
  
  <pre><code>void bar(const char* input) { ... }
  </code></pre>
  
  <p>Which one is safer to do:</p>
  
  <pre><code>bar(foo1().c_str());
  </code></pre>
  
  <p>or</p>
  
  <pre><code>bar(foo2());
  </code></pre>
  
  <p>If all I want to do is pass a string as an input to bar and then not care about the return value of either <code>foo</code> function will it actually matter?    </p>