11智能在线
新记
编写一个程序,判断输入字符串中的字符个数,不能用strlen()函数(长度不超过100)
如题所述
举报该文章
相关建议 2018-06-03
#include <stdio.h>
int len(char *s)
{
char *p;
for(p=s;*p;++p);
return p-s;
}
int main()
{
printf("%d\n",len("Hello World"));
return 0;
}
温馨提示:内容为网友见解,仅供参考
当前网址:
https://11.t2y.org/zz/f27qqmvmqsqqf7fp8qq.html
其他看法
第1个回答 2018-06-03
int i = 0;
char a[100] = "Hello world!";
while(a[i] != '\0')
{
i++;
}
printf("%d",i);
相似回答
大家正在搜
相关问题
C编写程序,求所输入字符串的长度?(要求不能用strlen(...
编写程序,输入一个字符串,计算出这个字符串的长度(要求不能使...
编写一个C语言程序,功能为:输入一个字符串,不使用strle...
输入一个字符串,求其长度。(不能用strlen函数)
编写一个程序,求字符串的长度,不要使用strlen函数。
用C语言编写一道程序,求输入字符串的长度,且不能用strle...
从键盘上输入一个字符串,统计字符串中的字符个数。不许使用求字...
编写一个函数,用指针完成一个字符串长度,不能用strlen(...