I have the following c macro from the libpurple yahoo plugin:
#define yahoo_put16(buf, data) ( \
(*(buf) = (unsigned char)((data)>>8)&0xff), \
(*((buf)+1) = (unsigned char)(data)&0xff), \
2)
I want to implement the same as a function in my class witch would receive as a parameter a quint16 value and return it as a QByteArray I have the following but i don't seem to get the same result as with the macro above.
QByteArray YahooPacket::packQuint16(quint16 value) const
{
QByteArray data;
data.append(QByteArray::number((value >> 8) & 0xFF));
data.append(QByteArray::number(value & 0xFF));
return data;
}
How would i do to implement my function?