From mboxrd@z Thu Jan 1 00:00:00 1970 From: Helmut Djurkin Subject: Re: structure size Date: Wed, 05 Mar 2003 08:27:26 +0000 Sender: linux-c-programming-owner@vger.kernel.org Message-ID: <3E65B4EE.8080803@tscheinig.com> References: Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Id: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: Mohammed Khalid Ansari Cc: linux c programming mailing list hi, it's the alignment. with gcc and this: struct node { /* member here */ } __attribute__((packed)); you will get the your "collective sizes". Mohammed Khalid Ansari wrote: > Hi, > > why the sizeof sturcture is alway greater than the collective sizes of all > the elements in it. > > eg > struct node { > int a; > char c; > int b; > }; > > int main() > { > printf ("%d\n", sizeof (struct node)); > return 0; > } > > > it prints 12 in my case. > > where is the catch. >