#include <stdio.h>
int main (void)
{
char *str = "Hello"; //defining and initializing the str pointer, which is directing to 'H'.
printf("%s\n", str);
printf("%p\n", str);
return 0;
}
结果是:
Hello
0000000000404000
我的问题是 0000000000404000 是从哪里来的?
最佳答案
格式说明符 %p
将打印包含在 char* str
变量中的地址,而 %s
说明符将打印实际的字符串文字 你好
。内存中的地址 0x00000000 00404000
是 Hello
所在的位置。
关于c - 我真的很困惑理解 C 中的数组指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41154160/