int main() { char s1[80] = "abcdefg"; char* str1 = s1;//指针指向字符串地址 int n = 0; while (*str1 != NULL)//循环到指针==NULL时结束 证明到末尾了 { n++; str1++; //指向下一个地址 } printf("n=%d", n); return 0; }