Previous: Pointer-Integer Conversion, Up: Pointers [Contents][Index]
To print the numeric value of a pointer, use the ‘%p’ specifier. For example:
void print_pointer (void *ptr) { printf ("Pointer value is %p\n", ptr); }
The specification ‘%p’ works with any pointer type. It prints ‘0x’ followed by the address in hexadecimal, printed as the appropriate unsigned integer type.