I learned that when I initialize an array of chars it's just like initializing a pointer to chars. But, if that is the situation, why does the following code output strange characters?
char* returnMe()
{
char text[] = "Will I live forever?";
return text;
}
While the following code:
char* returnMe()
{
char* text = "Will I live forever?";
return text;
}
outputs:
Will I live forever?
What exactly are the differences between these two initializations? They both act like pointers, so if I do:
puts(X); //puts get char* as a parameter in it.
It will work for both cases (When I haven't gone out of scope yet.)