As a follow-up to this question:
From what I\'ve seen, this should work as expected:
void greet(){
char c[] = \"Hello\";
greetWith(c);
return;
Returning malloc'd memory from a function as suggested by several of the other responses is just asking for a memory leak. The caller would have to know you malloc'd it and then call free. If they happened to call delete on it, the results are undefined (although probably okay).
It would be better to force the caller to provide the memory for you and then copy your string into it. This way the caller is on notice that he/she needs to clean up.