C,C++

char -> WORD -> int (비트연산)

권멋져 2021. 2. 9. 08:39

* WORD = unsigned short = 2byte

* int = 4byte

* char = 1byte

 

 

char RxData[2048];

int nBlockNum = 0;
WORD temp = 0x00;

temp = RxData[0] & 0x00ff;
temp = temp + (RxData[1]<<8);

temp = temp & 0x0000FFFF;
nBlockNum = temp;