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

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

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

边栏推荐
- PR video clip (project packaging)
- Learning notes 8
- Moco is not suitable for target detection? MsrA proposes object level comparative learning target detection pre training method SOCO! Performance SOTA! (NeurIPS 2021)...
- 我国算力规模排名全球第二:计算正向智算跨越
- 【虚幻引擎UE】实现测绘三脚架展开动画制作
- mxnet导入报各种libcudart*.so、 libcuda*.so找不到
- After the deployment of web resources, the navigator cannot obtain the solution of mediadevices instance (navigator.mediadevices is undefined)
- Use of vscode software
- 在线文本行固定长度填充工具
- 3. Package the bottom navigation tabbar
猜你喜欢

Alibaba cloud ECS uses cloudfs4oss to mount OSS

CTF stegano practice stegano 9

User behavior collection platform

Wechat applet development process (with mind map)

函数(易错)

Pyqt pyside custom telescopic menu bar sharing (including tutorial)

As soon as I write the code, President Wang talks with me about the pattern all day

Network security - record web vulnerability fixes

技术教程:如何利用EasyDSS将直播流推到七牛云?

【科普】热设计基础知识:5G光器件之散热分析
随机推荐
OWASP top 10 vulnerability Guide (2021)
Get to know MySQL connection query for the first time
Ctfshow 2022 Spring Festival welcome (detailed commentary)
Use threejs to create geometry and add materials, lights, shadows, animations, and axes
File upload bypass summary (upload labs 21 customs clearance tutorial attached)
How to remove installed elpa package
Online text line fixed length fill tool
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)
如何优雅的获取每个分组的前几条数据
这是一个不确定的时代
Kwai, Tiktok, video number, battle content payment
A application wakes up B should be a fast method
Sequence diagram of single sign on Certification Center
About the recent experience of writing questions
Mixed compilation of C and CC
Machine learning decision tree
NetSetMan pro (IP fast switching tool) official Chinese version v5.1.0 | computer IP switching software download
Threejs implements labels and displays labels with custom styles
Use of vscode software
25K 入职腾讯的那天,我特么哭了