Hi,

I noticed something quirky with getting the size of a structure and comparing that to the sum of its individual parts. The size of the structure is 16 but the sum of the parts total 14. Any explanations? :-)
Regards,
ChuckB

Code:
  typedef struct {
    unsigned short type;       //WORD
    unsigned long size;        //DWORD
    unsigned short reserved1;  //WORD
    unsigned short reserved2;  //WORD
    unsigned long offset;      //DWORD
  } HEADER;  
  HEADER h;

  cout <<"type: " << sizeof(h.type) << endl;                    //2 bytes
  cout <<"size: " << sizeof(h.size) << endl;                      //4 bytes
  cout <<"reserved1: " << sizeof(h.reserved1) << endl;  //2 bytes
  cout <<"reserved2: " << sizeof(h.reserved2) << endl;  //2 bytes
  cout <<"offset: " << sizeof(h.offset) << endl;                //4 bytes
  cout <<"---------------------" << endl;
  cout <<"Size of h: " << sizeof(h) << endl << endl;;       //16 bytes
  cout <<"Size of HEADER: " << sizeof(HEADER) << endl; //16 bytes