//指针和数组的区别
char str[] = "I love fishC.com!";
int count = 0;
while (*str++ != '\0') // 报错,str 是一个地址,不是可修改的左值
{
count++;
}
printf("一共有%d个字符\n", count);
// 改进方式,如下
char str[] = "I love fishC.com!";
char *target = str;
int count = 0;
while (*target++ != '\0')
{
count++;
}
printf("一共有%d个字符\n", count);