when I run the code below, I got the result after the double slash.
it seems that when i output a pointer to int, it outputs the address in the pointer, but when i output a pointer to char, it outputs an array of chars in which the last char is a white space. Why!?
The C++ programming language simply specifically states that when you pass a char-pointer to cout through the << operator, it will output the char at that address and all following chars until it finds the value zero.
When you pass an int-pointer to cout through the << operator, it will output the value of the pointer (i.e. the address of the int that is being pointed at).
This is simply how the language works. In this case, a char-pointer is treated fundamentally differently to an int-pointer.
The reason behind this is (probably) historical. In C, a char-pointer is how one keeps hold of a string, so when someone passes a char-pointer to cout, they probably want that string to be output. It's a convenience provided to you by the language designers.
If you really do want the value of the char-pointer (i.e. the address of the char being pointed at) you can still get that.
A c-string is, in this context, a pointer-to-char. It would be awkward if the default behavior of std::cout was to print the address contained in a pointer-to-char rather than the string the user expected. A pointer to int, on the other hand, never points to a c-string, so there's no reason not to print the contained address.
If you want to print the address for a pointer-to-char, the usual way is to cast it to void*;