Subj : Sqfix problem To : Bob Jones From : Bo Simonsen Date : Sun Oct 05 2003 08:55 pm Hello Bob! 05 Oct 03 06:42, you wrote to me: BJ>> Ah.... That would explain it..... Yes, sizeof() may BJ>> not work in all environments now..... :( BS>> Well I just don't understand it, because it does BS>> normally work under Linux, maybe it's the arrays.. BJ> The problem is that sizeof() returns the number of bytes in BJ> memory. By default, structures are not packed. If the structure was BJ> packed, then sizeof() should have worked for reading and BJ> writing files. Oh! I thought so, but I wasn't scure about it. BJ> Wes has a define made to allow packing the structures BJ> under GCC but not on other compilers where the packing isn't needed. It's needed for use with fx. OS/2 or Win32, BTW one of my links told that the user.bbs from a Max/2 can't be readed by Max/Linux BJ> Any structure that has more than one item (which it should or you BJ> wouldn't have used a structure), and has elements that are not an BJ> exact multiple of 4 or 8 bytes may get located on 4 (or 8) byte BJ> boundaries, resulting in unused bytes in the structures memory immage. Ah! BJ> So, sizeof() is needed for memory copies, but fail when BJ> reading and/or writing binary files in these cases..... I see :-) Thanks for the explanation! Regards, Bo --- GoldED+/LNX 1.1.4.7 * Origin: The Night Express, Roennede Dk (2:236/100) .