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

}

相关推荐
吃西瓜的年年1 小时前
1. 初识C语言
c语言·开发语言
永远都不秃头的程序员(互关)2 小时前
C语言 基本语法
c语言·开发语言
赖small强3 小时前
【Linux C/C++开发】Linux 平台 Stack Protector 机制深度解析
linux·c语言·c++·stack protector·stack-protector·金丝雀机制
liu****4 小时前
3.链表讲解
c语言·开发语言·数据结构·算法·链表
赖small强5 小时前
【Linux C/C++开发】Linux C/C++ 堆栈溢出:原理、利用与防护深度指南
linux·c语言·c++·stack·堆栈溢出
赖small强6 小时前
【Linux C/C++开发】Linux C/C++ 高效延迟崩溃分析:基于 mprotect 的内存陷阱技术 (Electric Fence)
linux·c语言·c++·mprotect·buffer overflow
繁华似锦respect6 小时前
C++ & Linux 中 GDB 调试与内存泄漏检测详解
linux·c语言·开发语言·c++·windows·算法
ULTRA??8 小时前
C语言简化版本开辟动态内存的万能MALLOC宏封装
c语言·开发语言
2401_861277558 小时前
func(int* num)的实现是*num=2或者int a=3,num=&a都可以吗
c语言·c++
我要升天!9 小时前
QT -- 网络编程
c语言·开发语言·网络·c++·qt