Consider the function:
char *func()
{
return "Some thing";
}
Is the constant string (char array) "Some thing" stored in the stack as local to the function call or as global in the heap?
I’m guessing it’s in the heap.
If the function is called multiple times, how many copies of "Some thing" are in the memory? (And is it the heap or stack?)
String literal “Some thing” is of type
const char*. So, they are neither on heap nor on stack but on a read only location which is a implementation detail.From Wikipedia