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

}

相关推荐
liebe1*11 小时前
C语言程序代码(四)
c语言·数据结构·算法
chao1898443 小时前
C 文件操作全解速览
服务器·c语言·c#
青光键主3 小时前
C语言内功强化之const修饰指针
c语言·开发语言
hazy1k5 小时前
51单片机基础-TFT LCD 显示(ILI9341,SPI 4线)
c语言·stm32·单片机·嵌入式硬件·51单片机
奔跑吧邓邓子5 小时前
【C语言实战(63)】从0到1:51单片机GPIO控制实战秘籍
c语言·51单片机·开发实战·gpio控制实战
向前阿、7 小时前
数据结构从基础到实战——排序
c语言·开发语言·数据结构·程序人生·算法
Doro再努力8 小时前
数据结构04:链表的概念及实现单链表
c语言·数据结构
矮油0_o8 小时前
15.套接字和标准I/O
服务器·c语言·网络·网络编程·socket
Jie_jiejiayou8 小时前
按键防抖 — 工业级标准实现总结(STM32)
c语言·stm32·按键消抖
散峰而望10 小时前
C语言刷题(一)
c语言·开发语言·编辑器·github·visual studio