cout<with char*参数打印字符串,而不是指针值这是:const char * terry = "hello";cout<<terry;版画hello而不是'h'..为什么会发生这种事?
3 回答
拉风的咖菲猫
TA贡献1995条经验 获得超2个赞
std::cout
char *
cout << (void *) terry;
const void *
static_cast
cout << static_cast <const void *> (terry);
void *
#include <iostream>int main (void) { const char *terry = "hello"; std::cout << terry << '\n'; std::cout << (void *) terry << '\n'; std::cout << (const void *) terry << '\n'; std::cout << static_cast<const void *> (terry) << '\n'; return 0;}
hello0x80488700x80488700x8048870
static_cast
static_cast <void *>
const_cast
MM们
TA贡献1886条经验 获得超2个赞
cout << static_cast<const void*>(terry);
<<
- 3 回答
- 0 关注
- 545 浏览
添加回答
举报
0/150
提交
取消