The statement
int a[] = { 2,1,4,3,6,5,8,7,10,9 };
Looks like this in memory
+---+---+---+---+---+---+---+---+---+---+
a -> | 2 | 1 | 4 | 3 | 6 | 5 | 8 | 7 | 10| 9 |;
+---+---+---+---+---+---+---+---+---+---+
+0 +1 ...
When you access elements in the array you typically use [] but since a is an address. you can access
elements also using a pointer style offset
a + 2 // address to third int, *(a+2) the actual value `3`
Now by declaring another way to access the 10 integers you can access the memory of a in a different way, the type determines the way you access the memory
int(*b)[5] = (int(*)[5]) a; // compiler, pretend a is of same type
In the above statement b and a refer to the same memory but b is of type pointer to int array of five.
since b is a pointer:
b points to where a starts. doing b++, b now points to middle of a array since declaration of b says it holds only five integers
so
b[0] points to address a + 0
b[0][0] is the value of a + 0 or a[0] alt. *(a + 0)
b[1] points to address a + 5
b[1][0] is the value of a + 5 or a[5] alt. *(a + 5)
Since C normally has no check whether you are going out of bounds the above works.
a(int[10]) toint(*)[5].(int(*)[5]) a?ais an array(int[10]). Andint(*)[5]means a point. Can they convert directly?(int(*)[5]) a?ais an array(int[10]). Andint(*)[5]means a point. Can they convert directly?