当前位置:网站首页>Is the array name the address of the first element?
Is the array name the address of the first element?
2022-07-27 15:45:00 【FA FA is a silly goose】
The array name is indeed the address of the first element , But there are two exceptions .
1.sizeof( Array name ), The array name here is not the first element address , Represents the entire array .
Code up :
int arr[10] = {
0 };
printf("%d\n", sizeof(arr));
The result is :
If it is the address of the first element , stay 32 The size of the bit platform address is 4 Bytes ,64 The bit platform address size is 8 Bytes , But the output here is 40 byte , therefore sizeof( Array name ) This situation , The array name represents the entire array .
2.& Array name , The array name here also represents the whole array .
Code up :
int arr[10] = {
0 };
printf("%p\n", &arr);
printf("%p\n", &arr[0]);
printf("%p\n", &arr[0]+1);
printf("%p\n", &arr+1);
The result is :
&arr[0] and &arr[0]+1 Each represents an array arr The address of the first element and the address of the first element , The difference is 4, It's exactly the size of a plastic , We'll see &arr and &arr+1 The difference is 40,, Is precisely 10 The size of a plastic , therefore &arr Medium arr Represents the entire array .
边栏推荐
- Set the position of the prompt box to move with the mouse, and solve the problem of incomplete display of the prompt box
- npm install错误 unable to access
- Alibaba's latest summary 2022 big factory interview real questions + comprehensive coverage of core knowledge points + detailed answers
- Hyperlink parsing in MD: parsing `this$ Set() `, ` $` should be preceded by a space or escape character`\`
- QT (five) meta object properties
- C语言:动态内存函数
- 【剑指offer】面试题46:把数字翻译成字符串——动态规划
- JS operation DOM node
- 设置提示框位置随鼠标移动,并解决提示框显示不全的问题
- $router.back(-1)
猜你喜欢

flutter —— 布局原理与约束

C语言:三子棋游戏

数组名是首元素地址吗?
![[0 basic operations research] [super detail] column generation](/img/cd/f2521824c9ef6a50ec2be307c584ca.png)
[0 basic operations research] [super detail] column generation

Spark 3.0 DPP implementation logic

C语言:扫雷小游戏

学习Parquet文件格式

Alibaba's latest summary 2022 big factory interview real questions + comprehensive coverage of core knowledge points + detailed answers

后台返回来的是这种数据,是什么格式啊

md 中超链接的解析问题:解析`this.$set()`,`$`前要加空格或转义符 `\`
随机推荐
C语言:自定义类型
js使用一元运算符简化字符串转数字
Network equipment hard core technology insider router Chapter 18 dpdk and its prequel (III)
兆骑科创创业大赛策划承办机构,双创平台,项目落地对接
flutter —— 布局原理与约束
go语言慢速入门——基本内置类型
On juicefs
Troubleshooting the slow startup of spark local programs
C:浅谈函数
Complexity analysis
【剑指offer】面试题50:第一个只出现一次的字符——哈希表查找
C language: factorial recursive implementation of numbers
The shell script reads the redis command in the text and inserts redis in batches
[TensorBoard] OSError: [Errno 22] Invalid argument处理
Set the position of the prompt box to move with the mouse, and solve the problem of incomplete display of the prompt box
Hyperlink parsing in MD: parsing `this$ Set() `, ` $` should be preceded by a space or escape character`\`
Catalog component design and custom extended catalog implementation in spark3
shell脚本读取文本中的redis命令批量插入redis
Binder initialization process
Multi table query_ Exercise 1 & Exercise 2 & Exercise 3