How to write a struct to a file?
Posted on 2006-07-13
I would like to know if there is any way to write a entira struct to a file.
I have a struct that i have got from a TCP connection it looks like this.
mes = static_cast<Message*>(VMes);
The mes is the structure and it looks like this
unsigned __int32 Time;
unsigned __int16 STX;
unsigned __int16 CRC;
unsigned __int16 MachID;
unsigned __int16 ClinicalSWID;
unsigned __int32 MsgCounter;
unsigned __int32 CmdCode;
unsigned __int32 MsgInfo;
unsigned __int32 Flags;
unsigned __int32 PatId;
I would now like to write mes to a file. I know that i can use ifstream but then i have to convert each element to string if i have't missunderstod it.
Is there a way to write the data without converting it?