+ 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
5 Réponses
+ 2
It should be the correct one, because b and &b return different values
+ 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.
+ 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.
+ 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.
0
can I get more about what is a null pointer and
static initialisation