I worked with c pointers and could not explain the following code:
int main() { int i = -3; int *ptr; int **ptr2; int ***ptr3; ptr = &i; ptr2 = &ptr; ptr3 = &ptr2; printf("ptr = %p\n",(void *)ptr); printf("&ptr = %p\n",(void *)&ptr); printAddr(&ptr); printAddr2(&ptr2); printAddr3(&ptr3); return 0; } void printAddr(int **num) { printf("address of int ** = %p\n", (void *)&num); } void printAddr2(int ***num) { printf("address of int *** = %p\n", (void *)&num); } void printAddr3(int ****num) { printf("address of int **** = %p\n", (void *)&num); }
The output is as follows:
ptr = 0xbf9d64a0 &ptr = 0xbf9d64a4 address of int ** = 0xbf9d6490 address of int *** = 0xbf9d6490 address of int **** = 0xbf9d6490
My doubt is why you should go to (address(int)) == address(address(address(int))) ?
Thanks so much for the clarification.
I found this question to matter:
Recursive Pointers
But the author explicitly appoints them equal.
source share