当前位置:网站首页>[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
边栏推荐
- 安全面试之XSS(跨站脚本攻击)
- Database monitoring SQL execution
- Overview of LNMP architecture and construction of related services
- C language file operation
- Solutions to common problems in database development such as MySQL
- Harmonyos application development -- address book management system telmanagesys based on listcontainer [phonebook][api v6]
- 内网渗透之内网信息收集(四)
- 图书管理系统
- 数字电路基础(三)编码器和译码器
- 函数:字符串反序存放
猜你喜欢

Statistics, 8th Edition, Jia Junping, Chapter 11 summary of knowledge points of univariate linear regression and answers to exercises after class

captcha-killer验证码识别插件

Fundamentals of digital circuit (IV) data distributor, data selector and numerical comparator

JDBC看这篇就够了
![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]

Markdown font color editing teaching

Ucos-iii learning records (11) - task management

线程的实现方式总结

Mysql的事务是什么?什么是脏读,什么是幻读?不可重复读?

Statistics 8th Edition Jia Junping Chapter 12 summary of knowledge points of multiple linear regression and answers to exercises after class
随机推荐
数据库多表链接的查询方式
循环队列(C语言)
servlet中 servlet context与 session与 request三个对象的常用方法和存放数据的作用域。
Attack and defense world misc practice area (simplerar, base64stego, no matter how high your Kung Fu is, you are afraid of kitchen knives)
Keil5-MDK的格式化代码工具及添加快捷方式
MySQL中什么是索引?常用的索引有哪些种类?索引在什么情况下会失效?
内网渗透之内网信息收集(三)
《统计学》第八版贾俊平第四章总结及课后习题答案
Sentinel overall workflow
数字电路基础(二)逻辑代数
XSS (cross site scripting attack) for security interview
“人生若只如初见”——RISC-V
Function: calculates the number of uppercase letters in a string
The most popular colloquial system explains the base of numbers
《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
Binary search tree concept
《英特尔 oneAPI—打开异构新纪元》
Statistics 8th Edition Jia Junping Chapter 5 probability and probability distribution
Statistics, 8th Edition, Jia Junping, Chapter 11 summary of knowledge points of univariate linear regression and answers to exercises after class
JDBC transactions, batch processing, and connection pooling (super detailed)