[c++] How to get address of a pointer in c/c++?

You can use the %p formatter. It's always best practice cast your pointer void* before printing.

The C standard says:

The argument shall be a pointer to void. The value of the pointer is converted to a sequence of printing characters, in an implementation-defined manner.

Here's how you do it:

printf("%p", (void*)p);