有人可以向我解释为什么ints从用户那里获取的内容scanf()存储在8h分开的地址中,即使int我的64位机器的大小是4字节?它与内存中的对齐?
#include <stdio.h>
void main() {
int *a;
int i, n;
printf(" Input the number of elements to store in the array : ");
scanf("%d",&n);
printf(" Input %d number of elements in the array : \n",n);
printf("size of on int is %d\n", sizeof(i));
for(i=0;i<n;i++) {
printf(" element - %d : ",i+1);
printf("address of a is %p\n", &a+i);
scanf("%d",a+i);
}
return 0;
}
Input the number of elements to store in the array …Run Code Online (Sandbox Code Playgroud)