当前位置:网站首页>[C language errata] error in getting array length in function
[C language errata] error in getting array length in function
2022-07-19 03:41:00 【Tomorrowave】
How do we usually get the length of the array ?
Because the type of each element in the array is the same , The number of bytes in memory is the same , So the total number of bytes divided by the number of bytes occupied by an element is the length of the array .
int arr={
1,2,3,4,5,6}
int len = sizeof(arr)/sizeof(arr[0]); //6
Code up
because , The array passed in is the function parameter , In this function , Array is just a pointer ( Address , When the system runs this function , I don't know how much data storage space the address represented by the array has This is just to tell the function : The first address of a data storage space ), So the result is that the pointer variable occupies the memory size
void Reverse(int* arr)
{
int len=sizeof(arr)/(sizeof(arr[0]));
cout<<sizeof(arr)<<endl;
cout<<sizeof(arr[0])<<endl;
}

边栏推荐
- Oracle closes the recycle bin
- module_ Basic principle of init function
- 论文阅读:U-Net++: Redesigning Skip Connections to Exploit Multiscale Features in Image Segmentation
- Pure virtual function
- 代理模式——B站动力节点
- Powertor500t reports an error 0x01806803
- Zabbix6.0 monitoring vcenter7.0
- sublime基本操作
- 动态管理内存的通讯录实现
- MySQL addition, deletion, query and modification (basic)
猜你喜欢

SwiftUI 考试题库项目之支持题库和考试题库数量(教程含源码)

Powertor500t reports an error 0x01806803

Gnome boxes virtual machine creation and installation

Paper reading: u-net++: redesigning skip connections to exploit multiscale features in image segmentation

谷歌 Chrome 浏览器安装 PWA 应用将显示更多描述信息

Agent mode - power node of station B
![[MySQL] data query operation (select statement)](/img/22/9c20d80296622c4516f361654075d6.png)
[MySQL] data query operation (select statement)

GoogLeNet

Edge detection method -- first order edge detection

Envi: (the most detailed tutorial in 2022) custom coordinate system
随机推荐
leetcode:78. subset
KubeCon + CloudNativeCon Europe 2022
Wechat applet
爬虫学习(5):手把手教你爬虫requests实战演练
ulsm配置案例
Envi: (the most detailed tutorial in 2022) custom coordinate system
10. Redis interview FAQ
Chapter II linear table
第一章 绪论
10. Redis 面试常见问答
Vs code problem: launch:program '... \ vscode\launch. exe‘ dose not exist
支持工业级瘦设备4G接入,润和软件DAYU120通过OpenHarmony兼容性测评
Gnome boxes virtual machine creation and installation
[NoSQL] redis configuration and optimization of NoSQL (simple operation)
374. 猜数字大小(入门 必会)
Basic IDL content of note 1: common data types_ Create array_ Type conversion_ Print output_ Basic operation_ Relational operation
Theoretical basis of doubledqn and its code implementation [pytoch + pendulum-v0]
机器学习库Scikit-Learn(线性模型、岭回归、插入一列数据(insert)、提取所需列、向量机(SVM)、聚类)
oracle 关闭回收站
Thinkphp5.0 model operation uses page for paging