Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: sizeof struct Message-ID: <1989Sep6.163747.20267@utzoo.uucp> Organization: U of Toronto Zoology References: <29722@pbhya.PacBell.COM> Date: Wed, 6 Sep 89 16:37:47 GMT In article <29722@pbhya.PacBell.COM> afh@PacBell.COM (Alan Hobesh) writes: >The following c code prints the size of the definded structure to be 44, >when compiled on an AT&T 3B20 running UNIX V5.2.1.... >However, when the code is downloaded to a PC and compiled using Turbo C, >the size of the structure is reported to be 42. > >Why is there a difference and which is the correct size? There is a difference because compilers use different rules for filling in structures. Both sizes are correct; code that assumes *any* specific size for a struct is wrong. -- V7 /bin/mail source: 554 lines.| Henry Spencer at U of Toronto Zoology 1989 X.400 specs: 2200+ pages. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu