Structs and data modelling

This part of the C course builds a data model: a struct groups the fields of one object, a union shares their storage, and an enum names the states the object can be in. It puts const and restrict on the interfaces, hides the fields of an opaque type, and shows the design patterns a C program uses when it has no classes.

7.1 Structs definition, initialisation, members, padding, arrays of structs Open 7.2 Unions and bit-fields unions, tagged unions, bit-fields, portability Open 7.3 Enumerations enum constants, typedef, switch, values and flags Open 7.4 const and restrict const pointers, const parameters, restrict contracts Open 7.5 Opaque types and objects in C incomplete types, constructors, vtables, encapsulation Open 7.6 Design patterns in C strategy, observer, factory, state with function pointers Open

Lessons