当前位置:网站首页>[pointer] find the length of the string
[pointer] find the length of the string
2022-07-06 14:36:00 【|Light|】
requirement
Make up a function , Find the length of the string .( Use a pointer to achieve )
Code
/* * This function is used to calculate formal parameters a The length of the string pointed to * The calculated string length is returned as a function value * notes : System library functions cannot be used */
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 function
int main()
{
char a[300];
int n;
gets(a);
n=str_len(a);
printf("%d\n",n);
return 0;
}
test
Test input
Those engraved in the chair behind the love, will not like the cement on the flowers, out of no wind, lonely forest.
Output
116
边栏推荐
- 函数:字符串反序存放
- Detailed explanation of network foundation
- MySQL中什么是索引?常用的索引有哪些种类?索引在什么情况下会失效?
- 《统计学》第八版贾俊平第七章知识点总结及课后习题答案
- List and data frame of R language experiment III
- Pointers: maximum, minimum, and average
- XSS unexpected event
- Mysql的事务是什么?什么是脏读,什么是幻读?不可重复读?
- Fundamentals of digital circuit (V) arithmetic operation circuit
- 图书管理系统
猜你喜欢

sqqyw(淡然点图标系统)漏洞复现和74cms漏洞复现

Get started with Matplotlib drawing

5分钟掌握机器学习鸢尾花逻辑回归分类

5 minutes to master machine learning iris logical regression classification

MySQL中什么是索引?常用的索引有哪些种类?索引在什么情况下会失效?

Low income from doing we media? 90% of people make mistakes in these three points

Interview Essentials: what is the mysterious framework asking?

Network layer - simple ARP disconnection

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

Intranet information collection of Intranet penetration (I)
随机推荐
安全面试之XSS(跨站脚本攻击)
Intranet information collection of Intranet penetration (4)
Circular queue (C language)
《统计学》第八版贾俊平第一章课后习题及答案总结
Interview Essentials: what is the mysterious framework asking?
Statistics 8th Edition Jia Junping Chapter 10 summary of knowledge points of analysis of variance and answers to exercises after class
数据库多表链接的查询方式
Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary
flask实现强制登陆
MySQL中什么是索引?常用的索引有哪些种类?索引在什么情况下会失效?
《統計學》第八版賈俊平第七章知識點總結及課後習題答案
Feature extraction and detection 14 plane object recognition
MySQL interview questions (4)
数字电路基础(二)逻辑代数
数字电路基础(一)数制与码制
JVM memory model concept
移植蜂鸟E203内核至达芬奇pro35T【集创芯来RISC-V杯】(一)
关于超星脚本出现乱码问题
Résumé des points de connaissance et des réponses aux exercices après la classe du chapitre 7 de Jia junping dans la huitième édition des statistiques
Numpy Quick Start Guide