Hello,
I'm reading from a tcp server an integer (4-bytes) data
The tcp server is big endian
On my client, which is a little endian CPU, I've done this :
Qt Code:
QTcpSocket sck; qint32 v; ... sck.read(data, 16); #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN v = ntohl(*((qint32*) data)); #endifTo copy to clipboard, switch view to plain text mode
Works pretty well, but sounds "old school". Do I have a better way to do that ?
Thanks...
Bookmarks