N
nichas
the code is ...
int main(void){
static int a[]={1,2,3,4,5};
static int *p[5]={a,a+1,a+2,a+3,a+4};
int i;
for(i=0;i<5;i++){ printf("%u\n",a+i);}
printf("\n%u\t%u\t%d",p,*p,*(*p));
return 0;
}
Now in this code the output which iam getting is :::
the address of p is 4 added to the address of element 5 in the array
'a'. That means p points to the address of the memory location next to
a[4] (since on my machine int is 4 bytes). But what i guessed is that
it would point same as *p that is the element a[0]. I am not able to
think how this can happen.. please reply where i am wrong in my
thinking.
int main(void){
static int a[]={1,2,3,4,5};
static int *p[5]={a,a+1,a+2,a+3,a+4};
int i;
for(i=0;i<5;i++){ printf("%u\n",a+i);}
printf("\n%u\t%u\t%d",p,*p,*(*p));
return 0;
}
Now in this code the output which iam getting is :::
the address of p is 4 added to the address of element 5 in the array
'a'. That means p points to the address of the memory location next to
a[4] (since on my machine int is 4 bytes). But what i guessed is that
it would point same as *p that is the element a[0]. I am not able to
think how this can happen.. please reply where i am wrong in my
thinking.