当前位置:网站首页>函數(易錯)
函數(易錯)
2022-07-05 04:17:00 【曹樂樂愛學習】
函數傳遞數組,指針時候,傳遞的只是起始地址。
例:1維數組求和

發現,求的數組大小,等於2?而不是5?
解釋一下2是怎麼來的:因為我的是64比特機,而sizeof(int)大家都知道,4字節,32比特;所以sizeof(p),應該就是64;為什麼是64?因為第一句話我就說了:函數傳遞數組,指針時候,傳遞的只是一個地址,64比特機的地址,不就是64bit嘛。
所以,要把數組(指針)的大小,也要以形參的形式傳遞到函數裏面來。

--------------------------------------------------------------------------------------------------------------------
字符數組,由於末尾有'\0',所以有時候傳參時候可以不需要傳數組大小
例:删除字符串中的空格

边栏推荐
- Pyqt pyside custom telescopic menu bar sharing (including tutorial)
- Common features of ES6
- The development of mobile IM based on TCP still needs to keep the heartbeat alive
- 【虚幻引擎UE】实现测绘三脚架展开动画制作
- After the deployment of web resources, the navigator cannot obtain the solution of mediadevices instance (navigator.mediadevices is undefined)
- [understand series after reading] 6000 words teach you to realize interface automation from 0 to 1
- 阿里云ECS使用cloudfs4oss挂载OSS
- [phantom engine UE] only six steps are needed to realize the deployment of ue5 pixel stream and avoid detours! (the principles of 4.26 and 4.27 are similar)
- 根据入栈顺序判断出栈顺序是否合理
- Kwai, Tiktok, video number, battle content payment
猜你喜欢

Wechat applet development process (with mind map)

About the recent experience of writing questions

On the day 25K joined Tencent, I cried

Containerd series - detailed explanation of plugins

Threejs Internet of things, 3D visualization of farm (III) model display, track controller setting, model moving along the route, model adding frame, custom style display label, click the model to obt

Fuel consumption calculator

防护电路中的元器件

快手、抖音、视频号交战内容付费

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

Alibaba cloud ECS uses cloudfs4oss to mount OSS
随机推荐
Rome chain analysis
provide/inject
[thingsboard] how to replace the homepage logo
Machine learning -- neural network
A application wakes up B should be a fast method
Ctfshow web entry code audit
MacBook安装postgreSQL+postgis
web资源部署后navigator获取不到mediaDevices实例的解决方案(navigator.mediaDevices为undefined)
快手、抖音、视频号交战内容付费
北京程序员的真实一天!!!!!
Learning notes 8
Threejs Internet of things, 3D visualization of factory
Convert Boolean to integer value PHP - Convert Boolean to integer value PHP
Why can't all browsers on my computer open web pages
Use object composition in preference to class inheritance
Containerd series - detailed explanation of plugins
机器学习 --- 决策树
MySQL: view with subquery in the from clause limit
What is the reason why the webrtc protocol video cannot be played on the easycvr platform?
防护电路中的元器件