# Equivalent Pointer Expression

What is the equivalent pointer expression for referring the same element a[i][j][k][l]

#### Shiree Profile Answers by Shiree

• Apr 27th, 2010

*(a+i+j+k+l)

#### sachindra.shekhar Profile Answers by sachindra.shekhar

• May 6th, 2010

It should be

a[i][j][k][l]   => *(*(*(a+i) + j) + k) + l

#### KS111 Profile Answers by KS111

• Jun 21st, 2010

Similar to what Shekhar has already mentioned, with a small correction:
To print the value of a[i][j][k][l], we need to use *(*(*(*(a+i) + j) + k) + l).

Explanation:
Let us first take a simple example of a 2 dimensional array.
a[i][j]. Let the values be

a = 1
a = 2
a = 3

a = 4
a = 5
a = 6

a = 7

a = 8
a = 9

Since 'a' is 2 dimensional,
*a would give us '1'.
*(a+1) would give us '4', instead of 2.
The reason is that, a is a pointer to a single dimensional array.
So, it increments to the next single dimensional array.
*a would be pointing to the values set '1  2  3'
*(a+1) points to '4  5  6'
*(a+2) points to '7  8  9'

From here, it is like single dimensional array.
So we have +1 incrementing to the next element.
So, value at *(a+2) + 1, i.e., *( *(a+2) + 1) will give us 8, which is a
so *(*(a+i)+j) = a[i][j].

Similar concept can be applied for any dimensional array.
*(*(*(*(a+i) + j) + k) + l) = a[i][j][k][l]  