hi,
int a[][2]={1,2,3,4};
int *p[]={(int*)a,(int*)a+1, (int*)a+2};
for(i=0;i<2;i++)
for(j=0;j<2;j++)
printf("%d ",*(*(p+i)+j));
Firstly, This is part of any code. And i want to ask that in p[] definition, why it is written (int) with every element since a is already an pointer.
Secondly, when I am accessing ((p+1)+1) element in loop, then why it is giving o/p "3"(without quotes) ? Becuase according to me, (p+1) means "(int)a+1" which in turn means first element of the 2nd row. am i right ?
because a+1 means we are incrementing the row in 2-D array. please make me correct if i am wrong.
thanks in advance. please help.