title: Regarding structure padding in c++
body: <p>I use a datastructure in my project and in the context of a paricular structure i have a doubt about strucure padding. First Look at the strucure given below. I use Visual Studio 2008 compiler.</p>
  
  <pre><code>typedef struct tagDATA_PACK
  {
     DWORD dDataLength;
     BYTE bFlags;
     BYTE bAttrib;
     BYTE bOffset;
  }DATA_PACK;
  </code></pre>
  
  <p>Question1: How much is the size of the above structure?
     it shows 8 bytes. it is correct. But,</p>
  
  <p>consider the modified structure given below?</p>
  
  <pre><code>typedef struct tagDATA_PACK
  {
     DWORD dDataLength;
     BYTE bFlags;
  }DATA_PACK;
  </code></pre>
  
  <p>here the size is same as the above 8byte structure.
  My doubt here is, where would be the compiler adding the extra 3bytes?
  is it after BYTE bFlags or before it?</p>
  
  <p>All your answer is greatly appreciated.</p>