In a simple program like the following, where is the string literal stored? Is there a chance that the memory is overwritten between the call to GetMyString() and the output?
const char* GetMyString()
{
const char* myString = "This is my string";
return myString;
}
int main()
{
const char* st = GetMyString();
// do whatever
cout << st;
return 0;
}