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

}

相关推荐
wljy11 小时前
二、进制状态转换
linux·运维·服务器·c语言·c++
01_ice2 小时前
C语言数据在内存中的存储
c语言·开发语言
bucenggaibian2 小时前
《C语言》编程前置:计算机底层逻辑(诞生的基础)
c语言·程序框架·编译运行·内存地址·底层逻辑
小娄~~4 小时前
C语言卷子错题集
c语言·开发语言·数据结构
bucenggaibian9 小时前
C语言程序设计作业题
c语言·程序设计·常量·解答·作业题
小糯米60110 小时前
C语言 自定义类型:结构体 与 联合体
c语言·开发语言·数据结构
yzq19912711 小时前
10.C语言-表达式、左值与语句
c语言·指针·函数·表达式·语句
至为芯12 小时前
IP5356H_G3至为芯支持C口双向快充22.5W新国标移动电源方案芯片
c语言·开发语言
Byte Wizard13 小时前
自定义类型:联合和枚举
c语言·开发语言
搬砖的小码农_Sky14 小时前
macOS Sequoia上如何安装gcc/g++环境?
c语言·c++·macos