69,370
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
int length_string(char *s);
void main () {
char s1[50];
scanf("%s",s1);
printf("输入的字符串为:%s",s1);
int length;
length = length_string(s1);
printf("\n字符串长度为:%d\n",length);
}
int length_string(char *s) {
int i = 0;
while(*s != '\0') {
s++;
i++;
}
return i;
}