Returning a const char *

HI,

I have following function

static const char *aaa[] =
{
"hello"
"there"
}

const char * xyz(int i)
{
return aaa[i];
}

I want to make a change in the function xyz such that it returns the uppercase of the string. However, if a create a new char * in this function it will need to be deleted in the function that will call uppercase. Already alot code is using aaa and function xyz so I can not change the return type or in parameters for any of them. Kidly let me know how i can do it with out causing memory.

Thank you,
Ila
const char* is only good if you're storing an unchanging string literal.

If you need to modify the string, you're better off using std::string

Already alot code is using aaa and function xyz so I can not change the return type or in parameters for any of them


This is why it's so important to design before you code.
Topic archived. No new replies allowed.