Saturday, July 30, 2011

faqs about structure in C

C guarantees several things about structures:

  1. The first member of the structure starts at the same address as the structure itself, that is there is no padding before the first member.
  2. The members of the structure are allocated in the structure in the order of their declaration in the structure definition, they are never rearranged.
  3. The size of the structure will be greater than or equal to the sum of the sizes of its members, never less. There is another language down the hall where this is not always true.


No comments:

Post a Comment