Where are literal strings placed and why can I return pointers to them?

前端 未结 3 1021
有刺的猬
有刺的猬 2021-01-23 22:26

I stumbled upon this function in an answer to this question:

/* Note: I\'ve formatted the code for readability. */
const char * getString() {
    const char *x =         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-23 22:35

    It varies per ABI, but on x86 they're in static memory/DATA page, pointed to by the DS register.

提交回复
热议问题