Is this code a memory leak?

char *hello() {
return (char*)"Hello from hello...\n";
}


The function returns a pointer to a char array, which the array should be free after the function returns?

Or the returning char* is just a char array returned by value? If so, why not write char[] hello() in the first place?
It would be an error to try to delete the pointer returned by hello(), as the array it points to exists in static memory, not the heap.

It's not possible to return arrays from functions. char[] hello() is not syntactically valid.
Topic archived. No new replies allowed.