【发布时间】:2015-06-07 03:43:40
【问题描述】:
我运行了以下代码,这是我得到的输出:
#include <stdio.h>
int main()
{
int x = 3;
int y = x;
printf("%d\n", &x);
printf("%d\n", &y);
getchar();
return 0;
}
Output:
3078020
3078008
现在,每次我运行程序时,输出都会发生变化,但是 x 的位置与 y 的位置之间的差异总是 12。我想知道为什么。
编辑:我明白为什么差异是恒定的。我不明白的是为什么差值具体是12,为什么后面定义的y的内存地址小于x的。
【问题讨论】:
标签: c pointers memory int memory-address