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

}

相关推荐
山登绝顶我为峰 3(^v^)35 小时前
C/C++ 交叉编译方法
java·c语言·c++
LONGZETECH9 小时前
新能源汽车动力电池检测仿真教学系统:C/S 分层架构与数字化实训落地全解析
大数据·c语言·开发语言·人工智能·架构·系统架构·汽车
legendary_16311 小时前
SINK芯片:Type-C统一供电时代的小家电核心方案
c语言·开发语言·人工智能·智能手机
_Doubletful11 小时前
妙用位运算:解构汉明距离至100%(提供分析与多解)
c语言·算法·leetcode
shx_wei12 小时前
从函数调用到进程替换:使用 execl、CMake 与 PowerShell 构建一个多可执行程序
linux·c语言·windows·c
李小小钦14 小时前
D. Storming Arasaka(Codeforces 2238)
c语言·开发语言·数据结构·c++·算法
gugucoding1 天前
21. 【C语言】打包不同类型:结构体
c语言·开发语言
gugucoding1 天前
31. 【C语言】堆栈与队列的实现
c语言·开发语言·数据结构·链表
Yang_jie_031 天前
笔记:数据结构(C语言版)第一章知识点详细归纳
c语言·数据结构·算法
czhaii1 天前
串口1中断收发-C语言-MODBUS协议
c语言·开发语言