8 Complex Data Types

In this chapter, we’ll move beyond arrays and simple types to create more complex data types. We’ll start with a simple enum that defines a named list of items. Then we’ll look at structures and unions, which hold values of different types, accessed by name (unlike arrays, which contain values of a single type accessed by number or index). To make a custom data type, we’ll combine enums, structures, and unions. In addition, we’ll explore how structures are used in embedded programming. Finally, we’ll take a look at typedef, which allows us to define our own data type from existing types.

Enums

An enumerated type, or ...

Get Bare Metal C now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.