【发布时间】:2021-10-23 06:40:04
【问题描述】:
#include<iostream>
using namespace std;
int main(){
int a=1025;
int *p=&a;
cout<<"Size of integer is: "<<sizeof(int)<<" bytes"<<endl;
cout<<"Address= "<<p<<" Value= "<<*p<<endl;
char *p0;
p0=(char*)p;
cout<<"Size of char is: "<<sizeof(char)<<" bytes"<<endl;
cout<<"Address= "<<p0<<"Value= "<<*p0<<endl;
cout<<"It printed smilie above";
return 0;
}
为什么char的地址和值被打印成笑脸?
我得到的输出是:
Size of integer is: 4 bytes
Address= 0x61ff04 Value= 1025
Size of char is: 1 bytes
Address= ☺♦Value= ☺
【问题讨论】:
-
你希望它打印什么?