I think you want to have 1 byte alignment because you want to read from network directly into the structure. It's better to avoid lazyness and do it properly:

Qt Code:
  1. struct RECEIVEDATA {
  2. unsigned short tag;
  3. char name[10];
  4. char id[10];
  5. }; // assuming 22 bytes
  6. //...
  7. QByteArray ba = socket->read(22);
  8. item.tag = (ba.at(0) << 8) | ba.at(1);
  9. memcpy(item.name, ba.constData()+2, 10);
  10. memcpy(item.id, ba.constData()+12, 10);
To copy to clipboard, switch view to plain text mode