I have a stream to store and retrieve values from - to an structure


Qt Code:
  1. My_structure {
  2. int A;
  3. double B;
  4. };
  5.  
  6. put (My_structure &value) {
  7. const char * buffer ;
  8. buffer = reinterpret_cast<const char*> (&value);
  9. the_stream.write(buffer,sizeof value);
  10. }
  11.  
  12. get (My_structure & value) {
  13. char * buffer ;
  14. buffer = reinterpret_cast<char*> (&value);
  15. the_stream.get(buffer, sizeof value);
  16. value = *reinterpret_cast<My_structure*> (buffer);
  17.  
  18.  
  19. }
To copy to clipboard, switch view to plain text mode 

This compile but I get strange values.... (the tellg and tellp are well pointed to zero before starts the get's)
I dont know how to write this last line (value = ) to get the right values...

Any help would be appreciated.