摘要:
定义一个共同体跟定义struct的方式差不多首先定义一个结构体:typedef struct{ unsigned char floor; unsigned charroom; unsigned short region;}position;再定义一个共同体typedef union{position lightpos;unsigned char posbyte[4];}p;如果如下赋值:p.lightpos.floor = 0x10;p.lightpos.room = 0x01;p.lightpos.region = 0x0501;则:p.posbyte[0] = 0x10;p.posbyte 阅读全文