当前位置:网站首页>[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
边栏推荐
猜你喜欢

Ucos-iii learning records (11) - task management

循环队列(C语言)

Attack and defense world misc practice area (simplerar, base64stego, no matter how high your Kung Fu is, you are afraid of kitchen knives)

Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary

Hackmyvm target series (1) -webmaster

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

“Hello IC World”

移植蜂鸟E203内核至达芬奇pro35T【集创芯来RISC-V杯】(一)

Statistics, 8th Edition, Jia Junping, Chapter VIII, summary of knowledge points of hypothesis test and answers to exercises after class

Sqqyw (indifferent dot icon system) vulnerability recurrence and 74cms vulnerability recurrence
随机推荐
Record once, modify password logic vulnerability actual combat
Internet Management (Information Collection)
数字电路基础(二)逻辑代数
Function: find the root of the equation by Newton iterative method
2022华中杯数学建模思路
JDBC read this article is enough
Record an edu, SQL injection practice
JVM memory model concept
Function: find the maximum common divisor and the minimum common multiple of two positive numbers
【指针】统计一字符串在另一个字符串中出现的次数
How does SQLite count the data that meets another condition under the data that has been classified once
JDBC transactions, batch processing, and connection pooling (super detailed)
《统计学》第八版贾俊平第二章课后习题及答案总结
函数:计算字符串中大写字母的个数
《统计学》第八版贾俊平第八章假设检验知识点总结及课后习题答案
The most popular colloquial system explains the base of numbers
Hackmyvm target series (2) -warrior
【指针】八进制转换为十进制
内网渗透之内网信息收集(四)
Intranet information collection of Intranet penetration (I)