当前位置:网站首页>[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
边栏推荐
猜你喜欢
Library management system
Constants, variables, and operators of SystemVerilog usage
线程的实现方式总结
Ucos-iii learning records (11) - task management
Detailed explanation of network foundation
Harmonyos application development -- address book management system telmanagesys based on listcontainer [phonebook][api v6]
JDBC事务、批处理以及连接池(超详细)
《统计学》第八版贾俊平第十二章多元线性回归知识点总结及课后习题答案
Hackmyvm target series (2) -warrior
New version of postman flows [introductory teaching chapter 01 send request]
随机推荐
指针:最大值、最小值和平均值
《英特尔 oneAPI—打开异构新纪元》
【指针】求字符串的长度
Intranet information collection of Intranet penetration (2)
《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
《统计学》第八版贾俊平第六章统计量及抽样分布知识点总结及课后习题答案
Uibutton status exploration and customization
关于交换a和b的值的四种方法
数字电路基础(二)逻辑代数
Network technology related topics
The most popular colloquial system explains the base of numbers
Statistics, 8th Edition, Jia Junping, Chapter VIII, summary of knowledge points of hypothesis test and answers to exercises after class
Statistics 8th Edition Jia Junping Chapter 7 Summary of knowledge points and answers to exercises after class
Matplotlib绘图快速入门
c语言学习总结(上)(更新中)
【指针】使用插入排序法将n个数从小到大进行排列
Statistics, 8th Edition, Jia Junping, Chapter 6 Summary of knowledge points of statistics and sampling distribution and answers to exercises after class
JDBC事务、批处理以及连接池(超详细)
Function: calculates the number of uppercase letters in a string
2022华中杯数学建模思路