小编hor*_*zon的帖子

c程序 - 为什么以8h的间隔存储整数,即使它们占用4个字节

有人可以向我解释为什么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)

c memory int

-3
推荐指数
1
解决办法
71
查看次数

标签 统计

c ×1

int ×1

memory ×1