title: The return value of a LPCSTR function becomes trashy
body: <p>I was coding a simple XOR encryption program and then I noticed that the return value of a function is not the kind I expect to see.</p>
  
  <p>I just can't find a problem in my code, could anyone help me?</p>
  
  <p>Here's the program code:</p>
  
  <pre><code>#include "windows.h"
  #include "iostream"
  
  using namespace std;
  
  
  LPCSTR hasala(string original, char key){
  
    string changed;
  
    for (int temp = 0; temp &lt; original.size(); temp++){
    changed += original[temp] ^ (int(key) + temp) % 255;
    }
  
    cout &lt;&lt; changed.c_str()&lt;&lt;"\n\n";//works, output "acagaca"
  
    LPCSTR adart = changed.c_str();
  
    cout &lt;&lt; adart&lt;&lt;"\n\n";//works, output "acagaca"
  
    return adart;
  
  }
  
  int main(){
  
      cout &lt;&lt; hasala("abcdefg", 0);//doesn't work, output "||||@ER|||"...
  
      cout &lt;&lt; "\n\n";
  
      Sleep(8000);
  
      return 0;
  }
  </code></pre>