1 #include
2 #include
3 int main()
4 {
5 int i;
6 char *p={"this is a book"};
7 i = strlen(p);
8 printf("%d\n",i);
9
10 }
~
我的结果是14,编译器用的是gcc
可能是你的操作系统对vc6.0兼容性不好
你是要计算字符指针的长度还是字符串的长度。字符指针长度用sizeof(p)字符串长度用strlen(p)