C编写程序,求所输入字符串的长度?(要求不能用strlen( )函数直接求)

编写程序,求所输入字符串的长度?(要求不能用strlen( )函数直接求)
1楼的不对 无论输入什么字符 都是现实 length is 1

第1个回答  推荐于2018-02-28
#include "stdio.h"
void main()
{
char a[80];
int i=0;
gets(a);
while(a[i]!='\0')i++;
printf("%d",i);
}本回答被提问者和网友采纳
第2个回答  2009-12-23
假设要查的数组为s[],int i, t ; for (i=0;s[i]!=/0;i++)t=t+1;printf("%d",t);
第3个回答  2009-12-23
#include "stdio.h"
int slen(char *s)
{
int i;
for(i=0;i++;s[i]);
return i;
}
main()
{
char s[80];
scanf("%s",s);
printf("length is %d ",slen(s));
}
相似回答