且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在C中的数组中找到索引的地址

更新时间:2023-02-26 18:43:56

只要打印出变量的地址,就可以看到它!:

Just print the adress of the variable any you will see it!:

#include <stdio.h>  

int main() {

    int a[2][3][4][5];

    printf ("Size of int %d\n", sizeof(int));

    printf("Adress of the frist element \t%p\n", &a[0][0][0][0]);
    printf("Adress of x element \t\t%p\n", &a[1][1][1][1]);

    printf ("In decimal: \t\t\t%d\n", &(a[0][0][0][0]));
    printf ("In decimal: \t\t\t%d\n", &(a[1][1][1][1]));

    printf("Difference between the adresses %d", (char *)&a[1][1][1][1] - (char *)&a[0][0][0][0]);




    return 0;

}

之后,您可以检查您是否在正确的位置!

After that you can check if you where right!

如您所见,您的权利!它是 334

And as you see your right! it's 334