If you use &hello
it prints the address of the pointer, not the address of the string. Cast the pointer to a void*
to use the correct overload of operator<<
.
std::cout << "String address = " << static_cast<void*>(hello) << std::endl;
If you use &hello
it prints the address of the pointer, not the address of the string. Cast the pointer to a void*
to use the correct overload of operator<<
.
std::cout << "String address = " << static_cast<void*>(hello) << std::endl;