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

}

相关推荐
黎雁·泠崖1 小时前
栈与队列实战通关:3道经典OJ题深度解析
c语言·数据结构·leetcode
灵哎惹,凌沃敏12 小时前
FreeRTOS 任务上下文切换核心函数:xPortPendSVHandler详解
c语言·arm开发
喵了meme13 小时前
C语言实战练习
c语言·开发语言
White_Can13 小时前
《C++11:列表初始化》
c语言·开发语言·c++·vscode·stl
宵时待雨14 小时前
数据结构(初阶)笔记归纳1:复杂度讲解
c语言·数据结构·笔记
安生生申15 小时前
STM32 ESP8266连接ONENET
c语言·stm32·单片机·嵌入式硬件·esp8266
范纹杉想快点毕业17 小时前
嵌入式通信核心架构:从状态机、环形队列到多协议融合
linux·运维·c语言·算法·设计模式
网安_秋刀鱼17 小时前
【java安全】反序列化 - CC1链
java·c语言·安全
Ljubim.te17 小时前
inline介绍,宏定义的注意事项以及nullptr
c语言·开发语言·c++
苦藤新鸡18 小时前
6.三数之和
c语言·c++·算法·力扣