C++ int类型转换为byte类型
int num = 7;
//定义一个4字节的结构体
struct A
{
unsigned char a;
unsigned char b;
unsigned char c;
unsigned char d;
};
A obj;
//强转为DWORD,然后将int赋值给DWORD int 4字节 DWORD 4字节
DWORD *dw = (DWORD*)&obj;
*dw = num;
//假设有一个byte[4]的数组
byte[0] = obj.a;
byte[1] = obj.b;
byte[2] = obj.c;
byte[3] = obj.d;