#include <stdio.h>
#pragma pack(4)
int main(int argc, char* argv[])
{
unsigned char puc[4];
struct tagPIM
{
unsigned char ucPim1;
unsigned char ucData0:1;
unsigned char ucData1:2;
unsigned char ucData2:3;
}*pstPimData;
pstPimData = (struct tagPIM *)puc;
memset(puc, 0, 4);
pstPimData->ucPim1 = 1;
pstPimData->ucData0 = 1;
pstPimData->ucData1 = 3;
pstPimData->ucData2 = 4;
printf("%02X %02X %02X %02X\n", puc[0], puc[1], puc[2], puc[3]);
/*
int i;
for(i = 0; i < 8; ++i)
{
printf("%d\n", puc[1] & (0x1 << i));
}
*/
return 0;
}
#pragma pack()
|