当前位置:网站首页>【指针】求字符串的长度
【指针】求字符串的长度
2022-07-06 09:24:00 【|光|】
要求
编一个函数,求字符串的长度。(用指针实现)
代码
/* * 该函数用来实现计算形参a所指向的字符串的长度 * 计算得到的字符串长度以函数值方式返回 * 注:不能使用系统库函数 */
int str_len(char *a)
{
int len=0;
for(int i=0;i<300;i++)
{
if(a[i]=='\0')
break;
else
len++;
}
return len;
}
main函数
int main()
{
char a[300];
int n;
gets(a);
n=str_len(a);
printf("%d\n",n);
return 0;
}
测试
测试输入
Those engraved in the chair behind the love, will not like the cement on the flowers, out of no wind, lonely forest.
输出
116
边栏推荐
- 《統計學》第八版賈俊平第七章知識點總結及課後習題答案
- Attack and defense world misc practice area (simplerar, base64stego, no matter how high your Kung Fu is, you are afraid of kitchen knives)
- Captcha killer verification code identification plug-in
- . Net6: develop modern 3D industrial software based on WPF (2)
- 《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
- 数据库多表链接的查询方式
- 《统计学》第八版贾俊平第八章假设检验知识点总结及课后习题答案
- 浙大版《C语言程序设计实验与习题指导(第3版)》题目集
- Statistics 8th Edition Jia Junping Chapter 10 summary of knowledge points of analysis of variance and answers to exercises after class
- Sentinel overall workflow
猜你喜欢

内网渗透之内网信息收集(二)

搭建域环境(win)

《统计学》第八版贾俊平第九章分类数据分析知识点总结及课后习题答案

链队实现(C语言)

Captcha killer verification code identification plug-in
![Harmonyos application development -- address book management system telmanagesys based on listcontainer [phonebook][api v6]](/img/0b/ddbee0b8a34627e13bff5598bbaed8.jpg)
Harmonyos application development -- address book management system telmanagesys based on listcontainer [phonebook][api v6]

Statistics 8th Edition Jia Junping Chapter IX summary of knowledge points of classified data analysis and answers to exercises after class

Build domain environment (win)

四元数---基本概念(转载)

Binary search tree concept
随机推荐
外网打点(信息收集)
中间件漏洞复现—apache
线程的实现方式总结
How to earn the first pot of gold in CSDN (we are all creators)
XSS unexpected event
1.支付系统
What language should I learn from zero foundation. Suggestions
Wei Shen of Peking University revealed the current situation: his class is not very good, and there are only 5 or 6 middle-term students left after leaving class
How to turn wechat applet into uniapp
《统计学》第八版贾俊平第十二章多元线性回归知识点总结及课后习题答案
Statistics, 8th Edition, Jia Junping, Chapter VIII, summary of knowledge points of hypothesis test and answers to exercises after class
How does SQLite count the data that meets another condition under the data that has been classified once
Harmonyos application development -- address book management system telmanagesys based on listcontainer [phonebook][api v6]
使用 flask_whooshalchemyplus jieba实现flask的全局搜索
Data mining - a discussion on sample imbalance in classification problems
Proceedingjoinpoint API use
Lintcode logo queries the two nearest saplings
Harmonyos JS demo application development
Xray and Burp linked Mining
Network layer - simple ARP disconnection