Skip to content

Structures#

Structures in the C programming language are user-defined data types which allow for the grouping of multiple values of different data types in a single unit.

The syntax for declaring a structure is the following:

struct StructTag {
    data-type-1 memberName1;
    data-type-2 memberName2;
    // ...
};

The syntax for declaring a structure variable is the following:

struct StructTag variableName; 

Memory Layout#

The order of the members of a structure in memory is the same as their order in the declaration. However, padding bytes are inserted by the compiler to enforce the alignment of each member. The values of these bytes is undefined.