Path: utzoo!attcan!utgpu!watmath!att!cbnewsc!hartman From: hartman@cbnewsc.ATT.COM (mark.a.hartman) Newsgroups: comp.lang.c Subject: Re: sizeof struct Keywords: sizeof struct Message-ID: <2951@cbnewsc.ATT.COM> Date: 6 Sep 89 03:37:32 GMT References: <29722@pbhya.PacBell.COM> Reply-To: hartman@cbnewsc.att.com (mark.a.hartman) Distribution: na Organization: AT&T Bell Laboratories Lines: 28 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. > ... structure and code omitted ... > >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? The AT&T 3B20 compiler rounds structures up to an even word length, in your case from 42 bytes to 44. If you need code that is portable between the two machines, try adding something like char fill[2]; to the end of the structure to fill it out. Then, "sizeof struct" will be the same on both machines. -- Mark Hartman hartman@ihlpm.att.com ..att!ihlpm!hartman #include