直接上代码
#include <stdio.h>
char *test() {
// char res[] = "hello, world";
// return res;
return "hello, world";
}
const char *tt() {
const char *str = test();
printf("%s\n", str);
return str;
}
int main() {
const char *str = tt();
printf("%s\n", str);
}
结果是打印了两次 hello world, 注释是两个乱码
所以, 请问 return “hello, world” 的这个存储 hello, world 的内存在什么地方