![Quote](https://cboard.cprogramming.com/images/misc/quote_icon.png)
Originally Posted by
AndiPersti
[code]
Basically *&i == i, because & and * cancel.
That was my point at the above post! ![Big Grin](https://cboard.cprogramming.com/images/smilies/biggrin.png)
About tou example i think i got it.But let's check to be sure ![Wink](https://cboard.cprogramming.com/images/smilies/wink.png)
Code:
#include <stdio.h>
int main(void)
{
int i, *ptr1, **ptr2, ***ptr3;
i = 10;
ptr1 = &i;
ptr2 = &ptr1;
ptr3 = &ptr2;
printf("%d\n", i == **ptr2);
printf("%d\n", i == **&ptr1);
printf("%d\n", *&i == ***ptr3);
printf("%d\n", &i == **&*&ptr2);
return 0;
}
ptr2 is a 'double' pointer so because of line 9 points to ptr1 and then points(finally) to i.So line 12 will output 1.
Line 13 * cancels & so we have i==*ptr1,of course true,so output 1.
Line 14 is equivalent to i==***ptr3 which is true,becaues ptr3 is a 'triple pointer' which first points to ptr2(line 9),then points to ptr1 and finally points to i(the value of i).So output 1.
Line 15 is equivalent to &i==*ptr2 .ptr2 is a double pointer,so it points first to ptr1 and finally at the value 1.So *ptr2 is going to give us the value of ptr1,which is the adress of i and so output is going to be again 1.
Correct?