That's because cout::operator<<
has an overload for const char*
. You'll need an explicit cast to print the address:
cout<<static_cast<void*>(&i);
This will call the overload with void*
as parameter, which is the one used to print addresses.
Also note that your code runs into undefined behavior. You only have a single char there, and the overload expects a null-terminated C-string.