From: "Javier Calleja" To: "djgpp" Subject: Size of a struct is not correct Date: Thu, 2 Jul 1998 12:40:18 +0200 Message-ID: <01bda5a5$ce48b420$0100a8c0@dismuntel.ctv.es> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Precedence: bulk Hi world I have built the following struct: struct { char one; short two,three; long four } foo; But when I do sizeof of this struct, the result is wrong (it says the struct has 12 bytes). I think gcc tryes to allocate the struct variables in blocks of 4 bytes. But I have a problem, because I use the following sentence: memcpy(pointer_to_memory,&foo,sizeof(foo)); And I must to allocate each variable in a memory position of 9 bytes, when the first byte is one variable, the following two bytes are a short variable, ... Does anything have a solution? Thanks