c - 数组、指针地址值混淆

标签 c pointers

在运行下面的代码时,我得到了这个输出

num= 2359120, addr of num=2359120, *num=10,addr of num[0]=2359120

我无法理解 num 和 &num 如何具有相同的值。有什么帮助吗?我知道数组的名称本身就是一个指针

#include <math.h>
#include<stdio.h>
main()
{
int num[]={10,20,30,40,50};
printf("num= %d, addr of num=%d, *num=%d,addr of num[0]=%d\n",num,&num,*num,&num[0]);
}

最佳答案

数组num的名称与数组&num的地址相同,与第一个元素&num[0]的地址相同> 因此,你的输出。

关于c - 数组、指针地址值混淆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14927768/

相关文章:

c - 打印无符号短值

c - 为什么 C 中的类型转换需要括号?

c - 如何在 C 中实现 "private/restricted"函数?

C : scanf skips the first iteration while taking char* inputs from user through scanf

pointers - 如果在 P 设置为 nil 后将 C 类的字段 F 分配给指针 P,在 FreePascal 中会发生什么?

c - 如何在 C 中使用 strlen() 查找字符指针的长度?

c - 运行程序时出错 "Segmentation fault core dumped"

C 从文本文件中查找频繁出现的字符

c - 使用 GCC 在 C 中打印 printf long long int?

c++ - C和C++的指针区别