Please see following snap code. Sizes of individual members of structure are correct but when I print size of structure it gives two bytes extra.
#define BYTE unsigned char
#define INT16 unsigned short
typedef struct Element
{
BYTE ID;
BYTE Type;
BYTE Ptr;
INT16 Cnt;
INT16 Idx;
BYTE Status;
};
struct Element Element;
main()
{
printf("Size of BYTE %d\n",sizeof(Element.ID));
printf("Size of INT16 %d\n",sizeof(Element.Type));
printf("Size of WORD %d\n",sizeof(Element.Ptr));
printf("Size of DWORD %d\n",sizeof(Element.Cnt));
printf("Size of DWORD %d\n",sizeof(Element.Idx));
printf("Size of DWORD %d\n",sizeof(Element.Status));
printf("Size of Element %d\n",sizeof(struct Element));
}
I am working in VC++ 6.0 and on NT platform(0x86).
Size of struct element is 10, which is 2 bytes extra, if you add each member sizes. from where these two extra bytes came?
Is Borland 4.0 also exbhits same way?