How to simulate printf's %p format when using std::cout?
unsigned char *teta = ....; ... printf("data at %p\n", teta); // prints 0xXXXXXXXX How can I print variable address using iostream s? Is there a std:: ??? feature like std::hex to do this kind of conversion (address -> string), so std::cout << std::??? << teta << std::endl will print that address? (no sprintf's, please ;)) Cast to void* : unsigned char* teta = ....; std::cout << "data at " << static_cast<void*>(teta) << "\n"; iostreams generally assume you have a string with any char* pointer, but a void* pointer is just that - an address (simplified), so the iostreams can't do anything other