当前位置:网站首页>[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
边栏推荐
- Sword finger offer 23 - print binary tree from top to bottom
- “人生若只如初见”——RISC-V
- c语言学习总结(上)(更新中)
- 【指针】查找最大的字符串
- Statistics 8th Edition Jia Junping Chapter XIII Summary of knowledge points of time series analysis and prediction and answers to exercises after class
- Sqqyw (indifferent dot icon system) vulnerability recurrence and 74cms vulnerability recurrence
- 浙大版《C语言程序设计实验与习题指导(第3版)》题目集
- SystemVerilog discusses loop loop structure and built-in loop variable I
- 内网渗透之内网信息收集(四)
- 链队实现(C语言)
猜你喜欢
“人生若只如初见”——RISC-V
Uibutton status exploration and customization
Network technology related topics
数字电路基础(一)数制与码制
Build domain environment (win)
An unhandled exception occurred when C connected to SQL Server: system Argumentexception: "keyword not supported:" integrated
Record an API interface SQL injection practice
《英特尔 oneAPI—打开异构新纪元》
后台登录系统,JDBC连接数据库,做小案例练习
Constants, variables, and operators of SystemVerilog usage
随机推荐
《统计学》第八版贾俊平第二章课后习题及答案总结
Internet Management (Information Collection)
Function: find the maximum common divisor and the minimum common multiple of two positive numbers
【指针】使用插入排序法将n个数从小到大进行排列
Xray and burp linkage mining
【指针】数组逆序重新存放后并输出
How to test whether an object is a proxy- How to test if an object is a Proxy?
函数:求1-1/2+1/3-1/4+1/5-1/6+1/7-…+1/n
2022华中杯数学建模思路
Sqqyw (indifferent dot icon system) vulnerability recurrence and 74cms vulnerability recurrence
链队实现(C语言)
关于超星脚本出现乱码问题
Library management system
关于交换a和b的值的四种方法
【指针】八进制转换为十进制
Intranet information collection of Intranet penetration (5)
内网渗透之内网信息收集(三)
指针:最大值、最小值和平均值
XSS unexpected event
Sentinel overall workflow