I do not understand why the "C program" is giving the output 1
in line 1?
int main()
{
static int a[]= {10,20,30,40,50};
static int *p[]= {a,a+3,a+4,a+1,a+2};
int **ptr = p;
ptr++;
printf("%d,%d",ptr-p,**ptr); //line 1
return 0;
}
I ran the code on CodeBlocks:IDE. The output is 1,40
. I got why 40
part. But I don't understand is why 1
? From my understanding ptr-p
should give the difference in their address and that should be 4 as in 4 bytes.
Please kindly give a detailed explanation.
Thank you.