How to print the address of char array

You need to cast to void* to invoke correct overload of operator << instead of outputting as C strings

std::cout << static_cast<void*>(c) << std::endl;
std::cout << static_cast<void*>(c+3) << std::endl;

Leave a Comment