为什么显示指针的内容而不是地址

时间:2021-01-03 05:09:55

标签: c++ pointers reinterpret-cast

int main()
{

    int ch = 65;
    int *p = &ch;
    char *c = reinterpret_cast<char *>(p);
    cout<<*c<<endl;
    cout<<*p<<endl;

    cout<<"address:"<<c<<endl;
    cout<<"address:"<<p<<endl;

    return 0;
}

输出:

A
65
address:A // why content of c displaying cout<<"address:"<<c<<endl; instead of address
address:0x22ff24

0 个答案:

没有答案