结果为什么是0 1 5,想了好久没想出来,望指教
#include
#include
int main()
{
char p0[]="hello";
char *p1="hello";
char p2[11]="hello";
printf("%d\n",p0==p1);
printf("%zu\n",sizeof(*p2));
printf("%zu\n",strlen(p1));
return 0;
}
p0==p1肯定不成立,因为是两个字符串,首地址不同。所以输出0
sizeof(*p2),因为p2是char *类型,所以 * p2就是char类型,char类型长度为1,所以输出1
strlen(p1)是计算字符串p1的长度,p1共有5个有效字符,所以输出5