const char* str = "helloworld";
cout << str << endl; // 输出整个字符串helloworld
cout << (*str) << endl; // h
cout << (void*)str << endl; //首地址
int a = 112;
int* d = &a;
cout << d << endl; //输出a的地址值
cout << (*d) << endl; // 输出a的值112
为什么cout << str<< endl; 输出的就是整个字符串的值,
而cout << d << endl; 就是输出a首地址值
为什么输出的字符串的首地址值要通过(void*)str的方式来输出呢
登录后可查看更多问答,登录/注册