+ 2

How to store Pointer's memory location?

Pointers store memory location of other variables. How to store the memory location of pointer1 in pointer2

28th Aug 2016, 2:03 PM
Heeth Jain
Heeth Jain - avatar
2 Respuestas
+ 8
you can use a pointer to a pointer; example: int x=0; int *ptr1 = &x; int **ptr2 = &ptr1; in this case ptr2 store the address of ptr1. You can also change the value of x by dereferencing twice ptr2: main() { using namespace std; int x=0; int *ptr1 = &x; int **ptr2 = &ptr1; **ptr2 = 3; cout << "value of x is: " << x; return 0; } this will print 3 as the value of x, because you changed it using ptr2
28th Aug 2016, 4:25 PM
pleurobot
0
@pleurobot What does * and ** indicate in variable declaration
9th Sep 2016, 4:24 PM
Umed Jadhav
Umed Jadhav - avatar