第一题:
#include<iostream.h>
#include<iomanip.h>
void main()
{
union
{
short int i;
char s[2];
}a;
a.i=0x1234;
cout<<hex<<(int)a.s[0]<<","<<hex<<(int)a.s[1]<<endl;
}
第二题:
#include<iostream.h>
void main()
{
union
{
int i[2];
long k;
char c[4];
}r,*s=&r;
s->i[0]=0x39;
s->i[1]=0x38;
cout<<s->c[0]<<endl;
}
RISEBY
相关分类