题目:写一个函数,求一个字符串的长度,在main函数中输入字符串,并输出其长度。

题目:写一个函数,求一个字符串的长度,在main函数中输入字符串,并输出其长度。 

There is no nutrition in the blog content. After reading it, you will not only suffer from malnutrition, but also impotence.

The blog content is all parallel goods. Those who are worried about being cheated should leave quickly.

  

1.程序分析:

2.程序源代码:

main()

{

int len;

char *str20;

printf("please input a string:\n");

scanf("%s",str);

len=length(str);

printf("the string has %d characters.",len);

}

length(p)

char *p;

{

int n;

n=0;

while(*p!='\0')

{

 n++;

 p++;

}

return n;

}

相关推荐
Logic1011 小时前
C语言/数据结构字符串题解:按字符类型重排(数字→字母→符号)——三趟扫描稳定分区
c语言·数据结构·字符串·时间复杂度·计数排序·算法题·ascii
Logic1018 小时前
C语言/数据结构位运算题解:异或XOR找出学习计划中的“独特学习时间“——只出现一次的数字
c语言·数据结构·数组·位运算·时间复杂度·算法题·异或性质
wuminyu8 小时前
C++协程实现接收端的零拷贝Buffer管理原理剖析
java·linux·c语言·jvm·c++
思麟呀11 小时前
位运算:从一个整数到一个集合
c语言·数据结构·c++·算法
SuperByteMaster12 小时前
低功耗GPIO引脚配置
c语言
phltxy13 小时前
C 语言自定义类型:结构体、位段、枚举与联合体
c语言·开发语言
大侠归来14 小时前
C语言与C++在基础语法上的区别
java·c语言·c++
cu14315 小时前
细谈GM8229的具体功能与其应用
c语言·c++·人工智能·单片机
大侠归来16 小时前
C语言内存管理:从栈到堆的完整指南
c语言·开发语言·python
cu14316 小时前
细谈GM7123C的具体功能与其应用
c语言·c++·人工智能·嵌入式硬件