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

}

相关推荐
杨福瑞4 小时前
数据结构:双向链表(3)
c语言·数据结构·链表
热心网友俣先生7 小时前
2025年APMCM亚太数学建模C题AI+人工精翻版本+数据收集方式介绍+数据分享
c语言·人工智能·数学建模
闲猿类7 小时前
嵌入式第九天学习
linux·c语言·学习·算法·嵌入式
程序员与背包客_CoderZ7 小时前
C/C++版LLM推理框架Llama.cpp——入门与编码实战
c语言·开发语言·网络·c++·人工智能·语言模型·llama
Creeper.exe8 小时前
【C语言】函数
c语言·开发语言
赖small强8 小时前
【Linux C/C++开发】第20章:进程间通信理论
linux·c语言·c++·进程间通信
赖small强8 小时前
【Linux C/C++开发】第24章:现代C++特性(C++17/20)核心概念
linux·c语言·c++·c++17/20
SundayBear8 小时前
嵌入式操作系统进阶C语言
c语言·开发语言·嵌入式
yuuki23323311 小时前
【数据结构&C语言】排序大汇总
c语言·数据结构·后端·排序算法
雨落在了我的手上12 小时前
C语言入门 (二十):指针(6)
c语言