The struct keyword introduces or refers to a structure type through its structure tag. A structure combines named members that may have different types, unlike an array, whose elements share one base type. section 6.0 section 6.3
struct birdStruct {
char const* jay;
char const* magpie;
char const* raven;
char const* chough;
};
struct birdStruct const aName = {
.chough = "Henry",
.raven = "Lissy",
.magpie = "Frau",
.jay = "Joe",
};
This declaration defines struct birdStruct with four named pointer members; the later definition initializes an object and accesses members with the dot operator. section 6.3.1
Use structures to make data organization explicit:
- Declare the structure type separately from objects of that type; defining a struct type does not itself define an object. section 6.3.1
- Designate members by name with the dot operator, avoiding the ambiguity of assigning meaning to array indices. section 6.3.1
- Group unlike types, such as whole seconds and nanoseconds in struct timespec. section 6.3.2
- Nest structures when a member is itself a structure; nested declarations share the surrounding declaration's visibility rules. section 6.3.3
Representing a timestamp
A struct tm object can name calendar fields such as tm_year, tm_mon, and tm_mday. A function can accept a struct tm value, update tm_yday while accounting for leap years, and return the updated structure. section 6.3.1













