You're returning just a pointer while the array itself gets freed. An alternative is to have it return nothing, and instead accept a char pointer to an array created in main as an argument, which it will use to store the input.
I will pass the char array as parameter like you suggested. Just one question, though...
Aren't the "int" and the "string" freed also before return?
So it sounds like the general rule is that normal (non-pointer) local variables live long enough to be returned (at least live long enough to return the value to something in main) but anything a pointer points to is gone by the time the function returns?
a copy of the int or string is passed as the return value, so it's okay. The problem with arrays is that only the pointer is passed while the array if freed. If you were to make an object that contains an array, you could return that.