Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: C 字符串文字:它们去哪儿了?
如果我有以下代码
char *str = "Tryout" ;
字符串将存储在哪里?堆?如果是堆栈,那么指针是否指向堆栈位置?
该字符串具有静态存储类(可能在只读数据中)并且str是具有自动存储功能的局部变量。这就是为什么最好将其声明为const char *.
str
const char *