J
Jess
Hello,
If a function that returns an array of char like this one:
const char* f(){
return "abc";
}
then is the char array "abc" local/temporary object? I thought it
should be temporary and hence the returned pointer should point to an
undefined memory. However, a test showed I was wrong
int main(){
const char* p = f();
cout << p << endl;
}
it outputs "abc". Is the "abc" in "f" non-local?
Thanks,
Jess
If a function that returns an array of char like this one:
const char* f(){
return "abc";
}
then is the char array "abc" local/temporary object? I thought it
should be temporary and hence the returned pointer should point to an
undefined memory. However, a test showed I was wrong
int main(){
const char* p = f();
cout << p << endl;
}
it outputs "abc". Is the "abc" in "f" non-local?
Thanks,
Jess