#include <stdio.h>
#include <stdlib.h>
//定义结构体类型J
struct J
{
unsigned int j1:4;
unsigned int j2:4;
unsigned int j3:4;
unsigned int j4:4;
};
//定义联合体变量 bk,里面包含1个变量i和一个结构体类型为J的结构体变量j
union
{
unsigned int i;
struct J j;
} bk;
int main()
{
bk.i=0x1234;
printf("bk.i=0x%x\n",bk.i);
printf("bk.j.j1=0x%x\n",bk.j.j1);
printf("bk.j.j2=0x%x\n",bk.j.j2);
printf("bk.j.j3=0x%x\n",bk.j.j3);
printf("bk.j.j4=0x%x\n",bk.j.j4);
return 0;
}
先给低字节位赋值的
|