gpt4 book ai didi

c++ - 用 const char 指针分配的内存在哪里?

转载 作者:太空狗 更新时间:2023-10-29 17:14:36 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Is a string literal in c++ created in static memory?
C++ string literal data type storage

在这段代码中:

const char * str = "hello world";

如果我理解正确的话,一个指针是 4 或 8 个字节,我猜它会被分配到堆栈上。但是“hello world”的内存分配和存储在哪里呢?
或者 str 究竟指向什么?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com