1 votes 1 votes #include<stdio.h> int main() { int array[2][3]={5,10,15,20,25,30}; int (*ptr)[2][3]=&array; printf("%d\t",**(*ptr+1)); } can someone explain how is it "20"?? Programming in C programming-in-c pointers + – nish kim asked Sep 2, 2017 nish kim 1.6k views answer comment Share Follow See 1 comment See all 1 1 comment reply Pawan Kumar 2 commented Sep 2, 2017 reply Follow Share *(ptr+0) will point to first row *(ptr+1) will point to second row **(*ptr+1) will give the value at that location i.e. second row first column. 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes let array a[2][3]={5,10,15,20,25,30}; here a will hold the address of initial elements of array.... here *a=a and **a=*(*(a+1)+0)=a[1][0] will print 20....means 1th row and 0th column.... now in this case... (*ptr)[2][3]=&a ....then *ptr=a and then like above..... ,**(*ptr+1) also can be written as *(*(*ptr+1)+0) or *(*(a+1)+0) or a[1][0]..... hs_yadav answered Sep 2, 2017 hs_yadav comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes In computer a 2D array is stored in row major order and ptr is a pointer which points to the row of array means ptr+0 points to first row...ptr+1 points to second row so *ptr+1 points to the address of second row....and**(*ptr+1) will give the value stored at*ptr+1 i.e.,20 sandeepjkh answered Sep 2, 2017 • edited Sep 4, 2017 by sandeepjkh sandeepjkh comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes Hope this diagram helps you to understand. Tuhin Dutta answered Sep 4, 2017 • edited Sep 4, 2017 by Tuhin Dutta Tuhin Dutta comment Share Follow See all 0 reply Please log in or register to add a comment.