returning a pointer to a literal (or constant) character array (string)?

That is actually OK. The string literal is usually allocated in an immutable memory area that remains available for as long as your program is running.

See also the answers to when does c/c++ allocate string literals.

Leave a Comment