I was experimenting with array of pointers address calculation arithmetic.I got confused with the output of the above code.Could anyone explain whats happening?
void foo()
{
int i=10,k=3,l=20,m=30;
int *ary[2];
ary[0]=&i;
int b=20;
ary[1]=&k;
printf("%d\n",ary[0][1]);
}
Output is 3
Second program
void foo()
{
int i=10,k=3,l=20,m=30;
int *ary[2];
ary[0]=&i;
int b=20;
ary[1]=&b;
printf("%d\n",ary[0][1]);
}
Output is 20.
How is address calculation done in these above codes?
foo? There's a chance for undefined behavior...ari[1]is assigned&kin the first program and&bin the second.10on my mac.