#pragma pack(1)
typedef struct datainfo {
unsigned short bottom;
unsigned short savep;
unsigned short loadp;
unsigned char flags;
unsigned short maxlen;
} DATAINFO;
#pragma pack()
char buf[] = {00, 00, A9, 03, 7D, 05, 80, 40, 09};
DATAINFO *pdi = (DATAINFO *)buf;
//用下面的结构成员就可以使用该数据。如果有字节顺序,可以采用 htons 和 ntohs 进行转换:
pdi->bottom;
pdi->savep;
pdi->loadp;
pdi->flags;
pdi->maxlen;
复制代码