Padding for Struct Members
Learn more about how structures are represented in memory.
We'll cover the following
Introduction
Let’s revisit a previous example for a structure definition.
typedef struct
{
char x;
int y;
} TExample;
Assume the following declaration:
TExample p;
When representing it in memory, we may assume the following layout:
x
starts at the beginning ofp
.x
is 1 byte long.y
starts 1 byte afterx
.
Get hands-on with 1400+ tech skills courses.