编写一个求字符串的函数 参数用指针 在主函数中输入字符串 并输出其长度

如题所述

是不是要这样的程序啊:
#include<stdio.h>
//求字符串长度
int length(char *s){
int i=0;
while(s[i]) i++;
return i;
}
int main(){
char str[50];
int n;
scanf("%s",str);
n=length(str);
printf("%d\n",n);
}
温馨提示:答案为网友推荐,仅供参考
相似回答