title: C++ string: Invalid pointer error
body: <p>I am getting an invalid pointer error when I call the below function. Why is this happening?</p>
  
  <pre><code>void Get(const char* value)
  {
      string st("testing string");
      string val = st.substr(1, st.length()); 
      value = val.c_str();        
  }
  
  int main()
  {
      const char *val = NULL;
      GetVal(val);
      cout&lt;&lt;val;
  }
  </code></pre>
  
  <p>The objective is to return the substring.</p>