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

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;

}

相关推荐
想放学的刺客42 分钟前
单片机嵌入式嵌入式试题(第16期):硬件可靠性设计与复杂状态机架构设计
c语言·stm32·单片机·嵌入式硬件·物联网
巨大八爪鱼2 小时前
C语言纯软件计算任意多项式CRC7、CRC8、CRC16和CRC32的代码
c语言·开发语言·stm32·crc
浅念-2 小时前
链表经典面试题目
c语言·数据结构·经验分享·笔记·学习·算法
方便面不加香菜4 小时前
数据结构--栈和队列
c语言·数据结构
切糕师学AI5 小时前
ARM 中的 SVC 监管调用(Supervisor Call)
linux·c语言·汇编·arm开发
移幻漂流5 小时前
C/C++并发编程详解:如何写出优秀的并发程序
c语言·开发语言·c++
Jia shuheng6 小时前
#ifdef __cplusplus extern “C“ #endif的作用
c语言·嵌入式硬件
进击的小头7 小时前
创建型模式:简单工厂模式(C语言实现)
c语言·开发语言·简单工厂模式
范纹杉想快点毕业7 小时前
嵌入式工程师一年制深度进阶学习计划(纯技术深耕版)
linux·运维·服务器·c语言·数据库·算法
浅念-9 小时前
C语言——单链表
c语言·开发语言·数据结构·经验分享·笔记·算法·leetcode