当前位置:网站首页>用指针计算数组的个数
用指针计算数组的个数
2022-06-28 21:42:00 【51CTO】
利用了数组地址相减计算得到数组的元素个数
int
my_strlen(
char
*
str)
{
char
*
star
=
str;
char
*
end
=
str;
while (
*
end
!=
'\0')
{
end
++;
}
return
end
-
star;
}
int
main()
{
char
arr[]
=
"bit";
int
len
=
my_strlen(
arr);
printf(
"%d\n",
len);
return
0;
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
边栏推荐
- Binomial distribution (a discrete distribution)
- Study on bifunctional crosslinker lumiprobe sulfoacyanine 7 dicarboxylic acid
- 華為雲的AI深潜之旅
- Smarca2 antibody study: abnova smarca2 monoclonal antibody protocol
- Rosdep update using fishros to solve ros1/ros2 problems 2022
- Lumiprobe non fluorescent alkyne research - dbco NHS ester
- Activate function
- Proficient in data analysis, double the income? What is the strongest competitiveness
- LeetCode56. 合并区间
- 职场小技巧 | 了解岗位优势三板斧之“识人”
猜你喜欢

Webrtc audio and video development - experience

16 `bs对象.节点名div.属性contents` children descendants 获取子节点 子孙节点

ROS 2 Humble Hawksbill 之 f1tenth gym

Progress in visual weakly supervised learning

Rosdep update using fishros to solve ros1/ros2 problems 2022

Laravel文档阅读笔记-Adding a Markdown editor to Laravel

CVPR 2022 𞓜 a creative and aesthetic text generation method! Support any input

Activate function

Security dilemma of NFT liquidity agreement - Analysis of the hacked event of NFT loan agreement xcarnival

Postman introduction and installation steps
随机推荐
LeetCode:合并两个有序链表_21
Safety innovation practice | Haitai Fangyuan was invited to participate in the technical exchange Seminar on "network information innovation and value co creation in the digital age"
LeetCode213. 打家劫舍II
[width first search note] BFS output shortest path
If you are a C developer, look at these three explicit programming techniques
wrk压力测试工具介绍
PHP login problem
An artifact extracted from a well-known software and paid by a group of people
PAT 1021. Traversal of the deep root (25 points) graph, DFS, calculating the number of connected components
ROS 2 Humble Hawksbill 之 f1tenth gym
Google search is dying | DKB
Constructing the three-dimensional anti penetration of the actual combat defense system
城市大脑知识图谱构建及应用研究
LeetCode:二叉树展开为链表_114
Usage example of qjsonobject
加刚干的前提
QStringLiteral(str)
视觉弱监督学习研究进展
LeetCode121. The best time to buy and sell stocks
Laravel文档阅读笔记-Adding a Markdown editor to Laravel