Heap or Stack? When a constant string is referred in function call in C++

后端 未结 4 1008
梦毁少年i
梦毁少年i 2020-12-19 09:03

Consider the function:

char *func()
{
    return \"Some thing\";
}

Is the constant string (char array) \"So

4条回答
  •  忘掉有多难
    2020-12-19 09:32

    Neither, its in the static section of the program. Similar to having the string as a global variable. There is only ever one copy of the string within the translation unit.

提交回复
热议问题