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.

36 Structs definition, initialisation, members, padding, arrays of structs Open 37 Unions and bit-fields unions, tagged unions, bit-fields, portability Open 38 Enumerations enum constants, typedef, switch, values and flags Open 39 const and restrict const pointers, const parameters, restrict contracts Open 40 Opaque types and objects in C incomplete types, constructors, vtables, encapsulation Open 41 Design patterns in C strategy, observer, factory, state with function pointers Open

Lessons