Message-ID: <8D53104ECD0CD211AF4000A0C9D60AE3584548@probe-2.acclaim-euro.net> From: Shawn Hargreaves To: djgpp AT delorie DOT com Subject: Re: struct fields padding Date: Tue, 23 Feb 1999 13:11:47 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.0.1460.8) Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id IAA22702 Reply-To: djgpp AT delorie DOT com Rafael García writes: > I have programs that use binary files to index data files. > > I can work with the data files from DJGPP and from BC well, but the format > of structures seems to be different in both compilers because I cannot > recognize it from the other. It's not a good idea to just dump memory structures out to a disk file, because that kind of code is highly non-portable. Instead of using functions like fwrite() and fread(), write routines that will output just a single 16 or 32 bit value (using shifts and binary operators to split things up into a series of bytes that can be written out with a function like putc()), and change your file saving code to write each field individually using these helper functions. That way your routines will work correctly on any compiler or platform. Shawn Hargreaves.