44问答网
所有问题
请用C语言设计一个程序:输入一个字符串,计算其长度。
如题所述
举报该问题
推荐答案 2013-12-13
#include <stdio.h>
int main()
{
int n=0;
while(getchar()!='\n')
n++;
printf("%d",n);
}
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://44.wendadaohang.com/zd/YDWZYVZGV6GRGZZZYZK.html
其他回答
第1个回答 2013-12-13
#include <stdio.h>
size_t strlen(const char *s)
{
char *ts =s;
for(; *ts; ts++)
;
return ts-s;
}
int main()
{
char s[100];
fgets(s, 100, stdin);
printf("lenth =%d", strlen(s));
getchar();
return 0;
}
第2个回答 2013-12-13
;char a[n];gets(a);puts(a);printf("长度是%d位",strlen(a))
相似回答
大家正在搜