C++字符数组我用字符数组试验,然后我试图运行此程序:没有显示地址
#include <iostream>
using namespace std ;
int main ()
{
char *str = "Hello!" ;
cout << &str[0] << endl ;
cout << &str[1] << endl ;
cout << &str[2] << endl ;
cout << &str[3] << endl ;
cout << &str[4] << endl ;
return 0 ;
}
而且我不断收到这些输出:
Hello!
ello!
llo!
lo!
o!
正是这里发生了什么?我期待着十六进制值。
'字符*海峡= “你好”;'是C++ 11非法和之前弃用。 – chris