题目:写一个函数,求一个字符串的长度,在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;

}

相关推荐
Felven17 小时前
C. Brr Brrr Patapim
c语言·开发语言
Zwawa19 小时前
嵌入式OLED表驱动菜单:用一张表、一个栈和一个窗口重写表驱动菜单
c语言·单片机·嵌入式
沐晓时光1 天前
C语言入门,内存函数知识讲解
c语言·开发语言
Zwawa2 天前
C语言函数指针与宏实战:从回调、表驱动菜单到X-Macro,讲透嵌入式代码解耦
c语言·单片机·嵌入式
David猪大卫2 天前
【C++修炼】map 和 set 的使用
c语言·开发语言·数据结构·c++·经验分享·笔记·学习
HPtiger2 天前
C++ 入门笔记:从 C 到 C++ 的核心过渡(命名空间、输入输出、缺省参数、重载、引用、内联)
c语言·c++·学习
安妮细水长流2 天前
ad7124
c语言·单片机
Zwawa2 天前
用两个按键做一个OLED菜单:先把选择和执行分开
c语言·单片机·嵌入式
心仪久了会沦陷3 天前
C语言数据结构入门——树与二叉树详解:概念、堆实现与链式遍历
c语言·数据结构·算法
Severus_black3 天前
【C++初阶】list使用及相关实现,思路顺滑流畅!
c语言·数据结构·c++·stl·list