当前位置:网站首页>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 .
边栏推荐
猜你喜欢
随机推荐
flutter —— 布局原理与约束
synchronized和ReentrantLock的区别
【剑指offer】面试题50:第一个只出现一次的字符——哈希表查找
Hyperlink parsing in MD: parsing `this$ Set() `, ` $` should be preceded by a space or escape character`\`
[系统编程] 进程,线程问题总结
NPM install error unable to access
shell脚本读取文本中的redis命令批量插入redis
IP protocol of network layer
Analysis of spark task scheduling exceptions
C:浅谈函数
js使用for in和for of来简化普通for循环
C语言:字符串函数与内存函数
[正则表达式] 匹配多个字符
Pytorch replaces some components in numpy. / / please indicate the source of the reprint
UDP message structure and precautions
Transactions_ Basic demonstrations and transactions_ Default auto submit & manual submit
折半查找
《吐血整理》C#一些常用的帮助类
JS uses unary operators to simplify string to number conversion
Voice live broadcast system -- a necessary means to improve the security of cloud storage








