【发布时间】:2012-11-23 20:17:36
【问题描述】:
这是代码和输出:
int main(int argc, char** argv) {
bool a;
bool b;
cout<<"Address of a:"<<&a<<endl;
cout<<"Address of b:"<<&b<<endl;
int c;
int d;
cout<<"Address of c:"<<&c<<endl;
cout<<"Address of d:"<<&d<<endl;
char e;
cout<<"Address of e:"<<&e<<endl;
return 0;
}
输出:
a:0x28ac67的地址
b的地址:0x28ac66
c:0x28ac60的地址
d:0x28ac5c的地址
e的地址:
我的问题是: char的内存地址在哪里?为什么不打印?
谢谢。
【问题讨论】:
-
好奇,你用的是什么编译器?
-
你被 c++ 太聪明了一半搞砸了。 Plain ole c
printf没有这个问题,因为它不会尝试从参数的类型中推断出正确的格式。
标签: c++ char memory-address