Date: Sun, 7 May 1995 16:26:35 +0300 From: eliz AT is DOT elta DOT co DOT il (Eli Zaretskii) To: djgpp AT sun DOT soe DOT clarkson DOT edu, bob AT xnet DOT com Subject: Re: Int's need to be on paragraph boundaries? > i'm having an interesting problem. i have the following struct that i am > reading in from a file: > > char attrib; > unsigned short int numkeys; > unsigned long left; > unsigned long right; > char continue; > char *keys; > > the file physically reads as follows: > > hex: "01 F0 00 00 00 00 00 00 00 00 00 00 00 06 00 00 30 32 . . ." > > somehow a byte is getting lost, and it doesn't make much sense. i could That's because the compiler is free to pad structure fields to make memory accesses more efficient. If you want to make the structure packed (i.e. that its sizeof will be 13), use the __attribute__((packed)) extension of GNU C (it's in the docs).