当前位置:网站首页>函数(易错)
函数(易错)
2022-07-05 04:16:00 【曹乐乐爱学习】
函数传递数组,指针时候,传递的只是起始地址。
例:1维数组求和

发现,求的数组大小,等于2?而不是5?
解释一下2是怎么来的:因为我的是64位机,而sizeof(int)大家都知道,4字节,32位;所以sizeof(p),应该就是64;为什么是64?因为第一句话我就说了:函数传递数组,指针时候,传递的只是一个地址,64位机的地址,不就是64bit嘛。
所以,要把数组(指针)的大小,也要以形参的形式传递到函数里面来。

--------------------------------------------------------------------------------------------------------------------
字符数组,由于末尾有'\0',所以有时候传参时候可以不需要传数组大小
例:删除字符串中的空格

边栏推荐
- Open graph protocol
- [phantom engine UE] package error appears! Solutions to findpin errors
- Ctfshow web entry code audit
- MacBook installation postgresql+postgis
- [uniapp] system hot update implementation ideas
- 【thingsboard】替换首页logo的方法
- 【FineBI】使用FineBI制作自定义地图过程
- ClickPaaS低代码平台
- 长度为n的入栈顺序的可能出栈顺序种数
- Network layer - forwarding (IP, ARP, DCHP, ICMP, network layer addressing, network address translation)
猜你喜欢

The development of mobile IM based on TCP still needs to keep the heartbeat alive

Rust区块琏开发——签名加密与私钥公钥

About the prompt loading after appscan is opened: guilogic, it keeps loading and gets stuck. My personal solution. (it may be the first solution available in the whole network at present)

Why can't all browsers on my computer open web pages

蛇形矩阵

CTF stegano practice stegano 9

Uni app common functions /api

美国5G Open RAN再遭重大挫败,抗衡中国5G技术的图谋已告失败

3. Package the bottom navigation tabbar

As soon as I write the code, President Wang talks with me about the pattern all day
随机推荐
[phantom engine UE] package error appears! Solutions to findpin errors
Phpmailer reported an error: SMTP error: failed to connect to server: (0)
A real day for Beijing programmers!!!!!
The scale of computing power in China ranks second in the world: computing is leaping forward in Intelligent Computing
How to realize real-time audio and video chat function
kubernetes集群之调度系统
10种寻址方式之间的区别
ActiveReportsJS 3.1 VS ActiveReportsJS 3.0
Fuel consumption calculator
PR video clip (project packaging)
Seven join join queries of MySQL
Wechat applet development process (with mind map)
陇原战“疫“2021网络安全大赛 Web EasyJaba
MySQL: view with subquery in the from clause limit
Interview related high-frequency algorithm test site 3
25K 入职腾讯的那天,我特么哭了
C语言课设:影院售票管理系统
MacBook installation postgresql+postgis
学习MVVM笔记(一)
Bit operation skills