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?

3rd Jan 2021, 10:38 AM
Gogul
Gogul - avatar
1 Réponse
+ 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.
3rd Jan 2021, 10:57 AM
你知道規則,我也是
你知道規則,我也是 - avatar