title: Can C arrays contain padding in between elements?
body: <p>I heard a rumor that, in C, arrays that are contained inside structs may have padding added in between elements of the array. Now obviously, the amount of padding could not vary between any pair of elements or calculating the next element in an array is not possible with simple pointer arithmetic.</p>
  
  <p>This rumor also stated that arrays which are not contained in structures are guaranteed to contain no padding. I know at least that part is true.</p>
  
  <p>So, in code, the rumor is:</p>
  
  <pre><code>{
      // Given this:
      struct { int values[20]; } foo;
      int values[20];
  
      // This may be true:
      sizeof(values) != sizeof(foo.values);
  }
  </code></pre>
  
  <p>I'm pretty certain that <code>sizeof(values)</code> will always equal <code>sizeof(foo.values)</code>. However, I have not been able to find anything in the C standard (specifically C99) that explicitly confirms or denies this.</p>
  
  <p>Does anyone know if this rumor is addressed in any C standard?</p>
  
  <p><strong>edit</strong>: I understand that there may be padding between the end of the array <code>foo.values</code> and the end of the struct <code>foo</code> and that the standard states that there will be no padding between the start of <code>foo</code> and the start of <code>foo.values</code>. However, does anyone have a <em>quote from</em> or <em>reference to</em> the standard where it says there is no padding between the elements of <code>foo.values</code>?</p>