Can C arrays contain padding in between elements?

No, there will never be padding in between elements of an array. That is specifically not allowed. The C99 standard calls array types “An array type describes a contiguously allocated nonempty set of objects…”. For contrast, a structure is “sequentially”, not “contiguously” allocated.

There might be padding before or after an array within a structure; that is another animal entirely. The compiler might do that to aid alignment of the structure, but the C standard doesn’t say anything about that.

Leave a Comment