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

}

相关推荐
HABuo14 分钟前
【Linux进程(四)】进程切换&环境变量深入剖析
linux·运维·服务器·c语言·c++·ubuntu·centos
码农小韩2 小时前
基于Linux的C++学习——动态数组容器vector
linux·c语言·开发语言·数据结构·c++·单片机·学习
济6172 小时前
嵌入式C语言(第一期)
c语言·开发语言
逑之3 小时前
C语言笔记11:字符函数和字符串函数
c语言·笔记·算法
逑之3 小时前
C语言笔记1:C语言常见概念
c语言·笔记·c#
Felven3 小时前
A. Blackslex and Password
c语言
老鱼说AI3 小时前
现代计算机系统1.2:程序的生命周期从 C/C++ 到 Rust
c语言·c++·算法
项目題供诗4 小时前
C语言基础(二)
c语言·开发语言
逑之4 小时前
C语言笔记14:结构体、联合体、枚举
c语言·开发语言·笔记
朔北之忘 Clancy4 小时前
2020 年 6 月青少年软编等考 C 语言一级真题解析
c语言·开发语言·c++·学习·算法·青少年编程·题解