문제

I am trying to take 2. and 3. index content values from a char[3] array. How can I take these two bytes to copy, equaling to quint16 variable.

도움이 되었습니까?

해결책

Like this, for example:

char foo[3] = { 0x99, 0xEF, 0xBE };

quint16 bar = (quint8)(foo[1]) + (((qint8)(foo[2]))<<8);

qDebug() << hex << bar;

Output:

beef
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top