struct Base {
char a;
char b;
int i;
char c;
};
This video explains the concepts of structural padding and packing in C and C++. It details how compilers add extra bytes (padding) to structures to align data types for efficient processing, which can sometimes lead to larger-than-expected structure sizes. The video also discusses packing, a technique to minimize or eliminate padding to save memory, and the potential performance implications of both.
#pragma pack directive can be used to control packing and unpacking of structures, allowing developers to explicitly manage memory layout.