+ 4

How can I get the address of the pointer itself not the address to which the pointer is pointing but the addrrss of the memory location where the actual pointer is stored

Address of pointer

22nd Jul 2016, 7:31 AM
Vladislav Vulchev
Vladislav Vulchev - avatar
5 ответов
+ 2
It should be the correct one, because b and &b return different values
22nd Jul 2016, 9:00 AM
Tobias B.
Tobias B. - avatar
+ 2
@Tobias B. you can save &b to another one by using void* c=&b. means that its a raw pointer that point to pointer. also you can use int **c = &b. pointer to pointer.
15th Nov 2016, 6:19 PM
George Rabbat
George Rabbat - avatar
+ 1
#include <iostream> using namespace std; int a; int *b = &a; int main() { cout << b << endl; //pointer cout << &b; //points to pointer return 0; } But I dont know how to save &b to a variable.
22nd Jul 2016, 8:45 AM
Tobias B.
Tobias B. - avatar
+ 1
Thank you, I told of this way, but I wasn't sure if it's the correct one. In C++11 there is "std::addressof(ptr)", which, I think, does the thing.
22nd Jul 2016, 8:51 AM
Vladislav Vulchev
Vladislav Vulchev - avatar
0
can I get more about what is a null pointer and static initialisation
25th Jul 2016, 12:50 PM
Subramanian Thiagarajan
Subramanian Thiagarajan - avatar