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

}

相关推荐
凯子坚持 c21 分钟前
C语言复习概要(三)
c语言·开发语言
无限大.33 分钟前
c语言200例 067
java·c语言·开发语言
无限大.35 分钟前
c语言实例
c语言·数据结构·算法
Death20038 分钟前
Qt 中的 QListWidget、QTreeWidget 和 QTableWidget:简化的数据展示控件
c语言·开发语言·c++·qt·c#
Death2001 小时前
Qt 3D、QtQuick、QtQuick 3D 和 QML 的关系
c语言·c++·qt·3d·c#
洛临_1 小时前
【C语言】基础篇
c语言·算法
长天一色3 小时前
C语言日志类库 zlog 使用指南(第五章 配置文件)
c语言·开发语言
whltaoin3 小时前
【408计算机考研课程】-C语言认知
c语言·考研
一般清意味……3 小时前
快速上手C语言【上】(非常详细!!!)
c语言·开发语言
卑微求AC3 小时前
(C语言贪吃蛇)16.贪吃蛇食物位置随机(完结撒花)
linux·c语言·开发语言·嵌入式·c语言贪吃蛇