Re: sizeof (struct) differs from Windows and Linux. How can I fix this?



On Wed, 29 Dec 2004, John Cupitt wrote:

This is part of C: you can't write() a struct on one machine and
read() it on another. They may have different alignment rules (I think
this is the cause of your problem), or even different endian-ness.

Yup. Binary files are simply not portable. A possible alternative to John's suggestion is to save the information in text form (possibly structured text, e.g. XML) and read back into a struct from the text representation.

--
Allin Cottrell
Department of Economics
Wake Forest University, NC



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]