#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;
}
结果是:我真的很困惑与理解数组指针用C
Hello
0000000000404000
我的问题是从何而来0000000000404000?
输出中没有换行符?你应该做'printf(%p \ n“,(void *)str);''而不是'%p''期望一个'void'指针 – yano
这就是字符串碰巧到达地址空间的地方。 – user2357112
你有两个'printf's,你期望第二个'printf'做什么? – user3386109