16,543
社区成员




pragma pakc(push, 1)
struct
{
BYTE a;
BYTE b;
BYTE c[2];
}PARAM;
pragma pack(pop)
union PARAM
{
struct
{
BYTE a;
BYTE b;
BYTE c[2];
};
BYTE bb[4];
};
定义一个union就可以了
typedef struct
{
BYTE a;
BYTE b;
BYTE c[2];
}PARAM;
PARAM pm;
pm.a=0x01;
pm.b=0x02;
pm.c[0]=0x03;
pm.c[1]=0x04;
BYTE arr[100];
int a=sizeof(PARAM);
for(int i=0;i<a;i++)
{
arr[i]=((BYTE*)&pm)[i];
}