From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: Size of a struct is not correct Date: Thu, 02 Jul 1998 09:14:25 -0700 Organization: Alcyone Systems Lines: 27 Message-ID: <359BB1E1.1593B160@alcyone.com> References: <01bda5a5$ce48b420$0100a8c0 AT dismuntel DOT ctv DOT es> NNTP-Posting-Host: charmaine.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Javier Calleja wrote: > 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). This is perfectly valid. ANSI says that the compiler can do whatever padding it deems necessary. If you need a packed struct (which would make your program non-ANSI), see the FAQ for more information on what you can do. -- Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com Alcyone Systems / http://www.alcyone.com/max/ San Jose, California, United States / icbm:+37.20.07/-121.53.38 \ Regret it? nope. / Said it? yep. / Ice Cube