二维和三维阵列关系

时间:2013-12-13 16:07:37

标签: arrays

对于数组int数组[2] [3] [4];

i) array[0][0] == &array[0][0][0]
ii) array[0][1] == array[0][0][1]
iii) array[0][1]== &array[0][0][0]

看起来我什么都不等于

2 个答案:

答案 0 :(得分:0)

看起来i)是一个有效的陈述。等式的两边都指向3d数组中第一个元素的地址。

答案 1 :(得分:0)

试着理解你的问题。假设你在谈论C中的整数数组:

int array[2][3][4];
  1. 为真:array [0] [0]和& array [0] [0] [0]是相同的地址。
  2. 您正在将指针与整数(或任何类型的数组)进行比较。它不应该编译。
  3. 为false,这是有效的,因为您正在将int *与int *进行比较。但它显然不是同一个地址。

    array[0][0] is the address of array[0][0][0] but not of array[0][1][0]
    array[0][1] is the address of array[0][1][0]
    etc...
  4. 请记住:

    array is of type int***
    array[0] is of type int**
    array[0][0] is of type int*
    array[0][0][0] is of type int
    
相关问题