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

}

相关推荐
智者知已应修善业12 小时前
【51单片机数码管逐位显示1-8余位不亮】2024-10-23
c语言·经验分享·笔记·嵌入式硬件·51单片机
caimouse13 小时前
ReactOS 图形系统分析(47):GDI 批处理 — gdibatch.c
c语言·开发语言
caimouse14 小时前
ReactOS 窗口系统分析(1):窗口对象与创建 — window.c
c语言·开发语言
caimouse15 小时前
ReactOS 图形系统分析(53):系统库存对象 — stockobj.c
c语言·开发语言·spring
caimouse15 小时前
ReactOS 图形系统分析(52):OpenGL 支持 — wingl.c
c语言·开发语言
j7~16 小时前
【C语言】《C语言函数递归完全指南:思想、限制、经典例题(阶乘/斐波那契/青蛙跳台阶/汉诺塔)与迭代优化》
c语言·函数递归·汉诺塔问题·青蛙跳台阶问题·递归与迭代·n的阶乘
YSL07012417 小时前
动态内存管理
c语言
BreezeJuvenile17 小时前
基于C语言的SPSC环形缓冲区程序实现
c语言·环形缓冲区
SuperByteMaster18 小时前
recursive mutex的使用场景和场景代码
c语言
caimouse18 小时前
ReactOS 窗口系统分析(2):窗口类 — class.c
c语言·开发语言