What is Alignment and padding?
Placing data at addresses that are multiples of a number fixed for each type (alignment), and the unused bytes inserted between or after data items for that purpose (padding). In an environment where int is aligned on a 4-byte boundary, struct { char c; int i; char d; } gets 3 bytes after c and 3 bytes after d, for a size of 12 bytes. Reading or writing at a misaligned address is slower on some CPUs and raises an exception on others. Ordering members from the largest type down reduces padding.
Japanese name: アライメントとパディング
Alignment and padding appears in 2 practice questions across 2 topics, including ISA & Assembly, C Programming Basics.
Field: C Programming Basics