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

后端 未结 4 1002
梦毁少年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:48

    Neither on the heap, nor on stack, it is part of the so-called init section in the executable image (COFF). This is loaded into memory and contains stuff like strings.

提交回复
热议问题