The operator <<on std::coutwill process char*as a zero-terminated string. You will need to send it in void*to print the pointer value.
Try the following:
#include <iostream>
int main()
{
char x[6] = "hello";
std::cout << static_cast<void*>(x);
}
source
share