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

}

相关推荐
LDR0068 天前
Type-C 快充全面升级!LDR6601 赋能个人护理便携电机,重塑剃须刀 / 理发器新体验
c语言·开发语言
Luminous.8 天前
C语言--day30
c语言·开发语言
玖玥拾8 天前
C/C++ 数据结构(七)栈、容器适配器
c语言·数据结构·c++··容器适配器
謓泽8 天前
C语言不是语法,是通往机器的地图。
c语言·开发语言
不会C语言的男孩8 天前
Linux 系统编程 · 第 8 章:进程基础
linux·c语言
2601_951643888 天前
C语言长文整理,关键字和数据类型
c语言·数据类型·关键字·嵌入式开发·格式化输出
m0_547486668 天前
《C#语言程序设计与实践》 全套PPT课件
c语言·c#·c语言程序设计
✎ ﹏梦醒͜ღ҉繁华落℘9 天前
编程基础 --高内聚,低耦合
c语言·单片机
QK_009 天前
C语言 static 关键字三大作用
c语言·开发语言
隔窗听雨眠9 天前
C语言函数递归从入门到精通(下):性能优化与工程实践
c语言·算法·性能优化