+ 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
2 Respostas
+ 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
0
@pleurobot What does * and ** indicate in variable declaration