当前位置:网站首页>【指针】求字符串的长度
【指针】求字符串的长度
2022-07-06 09:24:00 【|光|】
要求
编一个函数,求字符串的长度。(用指针实现)
代码
/* * 该函数用来实现计算形参a所指向的字符串的长度 * 计算得到的字符串长度以函数值方式返回 * 注:不能使用系统库函数 */
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函数
int main()
{
char a[300];
int n;
gets(a);
n=str_len(a);
printf("%d\n",n);
return 0;
}
测试
测试输入
Those engraved in the chair behind the love, will not like the cement on the flowers, out of no wind, lonely forest.
输出
116
边栏推荐
- Database monitoring SQL execution
- Solutions to common problems in database development such as MySQL
- Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)
- XSS unexpected event
- Statistics 8th Edition Jia Junping Chapter 7 Summary of knowledge points and answers to exercises after class
- JVM memory model concept
- An unhandled exception occurred when C connected to SQL Server: system Argumentexception: "keyword not supported:" integrated
- AQS details
- Intranet information collection of Intranet penetration (4)
- Uibutton status exploration and customization
猜你喜欢

《英特尔 oneAPI—打开异构新纪元》

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

Solutions to common problems in database development such as MySQL

ES全文索引

Intranet information collection of Intranet penetration (4)

How to understand the difference between technical thinking and business thinking in Bi?

Windows platform mongodb database installation

"Gold, silver and four" job hopping needs to be cautious. Can an article solve the interview?

Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)

Sqqyw (indifferent dot icon system) vulnerability recurrence and 74cms vulnerability recurrence
随机推荐
JDBC read this article is enough
Statistics 8th Edition Jia Junping Chapter 7 Summary of knowledge points and answers to exercises after class
A complete collection of papers on text recognition
Statistics 8th Edition Jia Junping Chapter 10 summary of knowledge points of analysis of variance and answers to exercises after class
xray与burp联动 挖掘
MySQL interview questions (4)
Sqqyw (indifferent dot icon system) vulnerability recurrence and 74cms vulnerability recurrence
7-5 staircase upgrade (PTA program design)
Windows platform mongodb database installation
Realize applet payment function with applet cloud development (including source code)
Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)
{1,2,3,2,5}查重问题
Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary
Xray and burp linkage mining
This article explains in detail how mockmvc is used in practical work
sqqyw(淡然点图标系统)漏洞复现和74cms漏洞复现
Lintcode logo queries the two nearest saplings
Bing Dwen Dwen official NFT blind box will be sold for about 626 yuan each; JD home programmer was sentenced for deleting the library and running away; Laravel 9 officially released | Sifu weekly
循环队列(C语言)
[err] 1055 - expression 1 of order by clause is not in group by clause MySQL