Czesc
Szybkie pytanie - dlaczego ta struktura:
struct ST {
unsigned char t1; //1 bajt
unsigned long t2; //4 b
unsigned char t3; //1 b
};
po skompilowaniu programu zajmuje 12 bajtów? Chociaż wydaje sie ze powinna 6.. kompilator bawi sie w dziwne optymalizacje?
Jak moge uzyskac prawdziwy rozmiar?
Cały kod, do szybkiej kompilacji:
#include <stdio.h>
struct ST {
unsigned char t1;
unsigned long t2;
unsigned char t3;
};
int main() {
printf("%d\n", sizeof(ST)); //wyswietla 12
return 0;
}
Uzywam VS10, ale z tego co sprawdzilem pod gcc na linuxie jest to samo. Kompletnie tego nie rozumiem :|