title: c++ method chaining on returned value not working
body: <p>I am using cpp after a long time for an opengl project. I am facing a problem which is related to cpp not opengl in particular. What is the difference between the two code snippet bellow? </p>
  
  <pre><code>// this works
  std::string tmp = FileIO::read("vertex_shader");
  const char *vertexShaderSource = tmp.c_str();
  std::cout&lt;&lt; vertexShaderSource &lt;&lt;std::endl; //shows proper value
  
  //but this doesn't work 
  const char *vertexShaderSource = FileIO::read("vertex_shader").c_str();
  std::cout&lt;&lt; vertexShaderSource &lt;&lt;std::endl; //shows garbage value
  
  //FileIO::read() returns a string value
  </code></pre>
  
  <p>I am a bit confused why the first one works but the second one shows garbage? Am i missing something?</p>
  
  <p>Please any cpp experts enlighten me what is wrong on the second code snippet and why it doesn't work. Thanks in advance,</p>