Hi,
I'm developing a tcp-based server/client. I found a code to post a struct through tcp, but the data I get is looking weird. Here is what I have right now:

Qt Code:
  1. struct abc {
  2. char a;
  3. char b;
  4. };
  5.  
  6. abc *a = (abc*)malloc(sizeof(struct abc));
  7. a->a='1';
  8. a->b = '2';
  9.  
  10. QByteArray block;
  11. QDataStream out(&block, QIODevice::WriteOnly);
  12. out.setVersion(QDataStream::Qt_4_0);
  13.  
  14. out << (void*)a;
  15.  
  16. socket->write(block.data());
To copy to clipboard, switch view to plain text mode 

And here is the code to receive it:

Qt Code:
  1. char *data = (char*)this->socket->readAll().data();
  2.  
  3. QDataStream in(data);
  4. in.setVersion(QDataStream::Qt_4_0);
  5.  
  6. QByteArray block;
  7. in >> block;
  8.  
  9. abc *received;
  10. received = (abc*)data;
To copy to clipboard, switch view to plain text mode 

And when I debug this data, there are many strange characters instead of chars... What can be wrong?