I have a stream to store and retrieve values from - to an structure
My_structure {
int A;
double B;
};
put (My_structure &value) {
const char * buffer ;
buffer = reinterpret_cast<const char*> (&value);
the_stream.write(buffer,sizeof value);
}
get (My_structure & value) {
char * buffer ;
buffer = reinterpret_cast<char*> (&value);
the_stream.get(buffer, sizeof value);
value = *reinterpret_cast<My_structure*> (buffer);
}
My_structure {
int A;
double B;
};
put (My_structure &value) {
const char * buffer ;
buffer = reinterpret_cast<const char*> (&value);
the_stream.write(buffer,sizeof value);
}
get (My_structure & value) {
char * buffer ;
buffer = reinterpret_cast<char*> (&value);
the_stream.get(buffer, sizeof value);
value = *reinterpret_cast<My_structure*> (buffer);
}
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.
Bookmarks