0
int a[][3] = {1,2,3,4}; int (*p)[3] = a; printf("%d ",*p[0]); p++; printf("%d",*p[0]); O/P = 1 4. HOW POINTER ASSIGNED ABOVE 3?
Could anyone explain how pointer assigned after 3?
1 Odpowiedź
+ 3
a is a 2D array where each 1D array contains 3 elements. Assigning {1, 2, 3, 4} is equivalent to {{1, 2, 3}, {4}}.
p is a pointer to array that contains 3 elements and it's pointing to a. Doing p++ will result transfer it to the next array. Which is {4}. p[0] is 4.