int arr[4][3][2]
means arr
is 3D
array, consists four 2D
array, each 2D
array having three 1D
array and each 1D array
having two-two
elements.
Let’s Have a pictorial representation of arr
: Assume arr
base address is 0x100
.
arr[0][0][0] arr[1][0][0] arr[2][0][0] arr[3][0][0]
0x100 0x104 0x108 0x112 0x116 0x120 0x124 0x128 0x132 0x136 0x140 0x144 0x148 0x152 0x156 0x160 <--1D array elements
| | | | | | | | | | | | | | | |
---------- -------- ---------- ---------- ---------- ----------- ------------ ---------------
| | | | | | | |
arr[0][0] arr[0][1] arr[1][0] arr[1][1] arr[2][0] arr[2][1] arr[3][0] arr[3][1]
0x100 0x108 0x116 0x124 0x132 0x140 0x148 0x156 <---1D array
| | | | | | | |
------------------------ ------------------------- ------------------------- ------------------------
| | | |
arr[0] arr[1] arr[2] arr[3] <---2D array
0x100 0x116 0x132 0x148
| | | |
-------------------------------------------------------------------------------------------------------------------------
|
arr <---3D array
0x100
If you analyse above figure, you will come to know that arr
,arr[0]
,arr[0][0]
and &arr[0][0][0]
all are same
, all are holding arr
base address that is 0x100
.
Note that arr[0][0][0]
is value
but &arr[0][0][0]
is address
of first elements, so both are different
.
arr
and &arr
also same
because arr name itself address so by putting & doesn’t make any difference.
arr[0][0]
and &arr[0][0]
also same because arr[0][0]
is one dimensional array i.e single pointer
pointing to two elements called arr[0][0][0]
and arr[0][0][1]
.
as
arr[0][0] == & arr[0][0]
*( *(arr+0) + 0) == & *( *(arr+0) + 0)
*( *(0x100 + 0x16) + 0) == & *( *(0x100 + 0x16) + 0)
*( *(0x100)) == & *( *(0x100))
*( 0x100) == & *( 0x100)
0x100 == & 0x100
0x100 == 0x100
solved What are the following notations pointing to?