红联Linux门户
Linux帮助

关于Gcc字符输出,和内存问题

发布时间:2012-10-07 19:58:49来源:红联作者:胶头滴管3
今天在GCC上测试一个题目出现了,蛋疼的现象
首先我陈述一下:在c++中,32位机,int占4位32bit,short占2位16bit,long占4位32bit,char占1位
我在输出的时候程序如下
#include
using std::cout;
using std::endl;
int main()
{
union{short i[2];long k;char c[4];}r,*s=&r;
char m=0x39;
s->i[0]=0x39;s->i[1]=0x38;
cout<<(s->c[0])<
cout<c[1])< cout<<(s->c[2])< cout<<(s->c[3])< cout<<(s->i[0])<<'\t'<<(s->i[1])< cout<k)< cout< return 0;
}
在输出char型0x39怎么会输出9呢,是不是与unicode码有关??
文章评论

共有 0 条评论