Introduction to Structures

Structures are not a data type in themselves but rather a way for you to define your own data type. Moreover, with structures you can better model real-world objects. For example, if you wanted to create a list of books, storing the author, publication date, and title of each, you could do that with arrays: one array for the authors, one for the publication years, and a third for the titles (Figure 13.1). But such a construct would be less than ideal, at the very least because the three arrays would be seemingly unrelated. A better solution is to create one type of variable that can store the author's name, the title, and the publication date, all under one umbrella. This is where structures come in.

Figure 13.1. Using ...

Get C Programming: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.