Hello!
Please, in first function I created array a.
Function is returning POINTER of the array a.
In main, variable z is a pointer. But , is z an array.- or not?
If it is, I do not see where I have declared it as an array???
If z is NOT an array, how can we get vales for its elements(z[0], z[1], z[2])???
z is not an array. It is merely is a pointer to int. Subscript operator is absolute equivalent to the pointer arithmetics. Therefore z[0] == *(z + 0), z[1] == *(z + 1) etc. As you can use pointer arithmetics to access values in continuous memory, you can use subscript operator too.
Actually 1[z] is a valid way to do array subscription. More, following is valid too:
1 2
int array[2][2][2][2] = {};
1[0[array][1]][0] = 1;
1 A postfix expression followed by an expression in square brackets is a postfix expression. One of the expressions shall have the type “pointer to T” and the other shall have unscoped enumeration or integral type.
The result is an lvalue of type “T.” The type “T” shall be a completely-defined object type.62 The expression E1[E2] is identical (by definition) to *((E1)+(E2)) [ Note: see 5.3 and 5.7 for details of * and + and 8.3.4 for details of arrays. —end note]