题解 | 获取字符串长度
获取字符串长度
https://www.nowcoder.com/practice/9a2d212d23f5436c80607d5e68c6d12a
#include <stdio.h>
int main() {
char str[100] = { 0 };
gets(str);
char *p=str;
int count=0;
while (*p!='\0') {
count++;
p+=1;
}
printf("%d",count);
return 0;
}
利用指针在字符数组中遍历直至找到'\0'停止
