[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Как это понимать



Вопрос немного не в тему рассылки но тем не менее.
Есть простенькая прога на C:
==============
#include <stdio.h>
int main(void)
{
 struct oneRec
 {
  char b1;
   char b2;
  short id;
  char lang;
  char b3[2];
  char b4[2];

 };
 
 printf("sizeof(char)=%d\n",sizeof(char));
 printf("sizeof(short)=%d\n",sizeof(short));
 printf("sizeof(struct oneRec)=%d\n",sizeof(struct oneRec));
}

==============
У меня она выдает:
sizeof(char)=1
sizeof(short)=2
sizeof(struct oneRec)=10

А теперь считаем b1, b2 - по байту, id - 2 байта, lang - 1 байт, b3 = 2 байта, 
b4 = 2 байта. В сумме 9 байт. Но почему sizeof(struct oneRec)=10?

gcc version 3.3.5 (Debian 1:3.3.5-8)



Reply to: