Chapter 25 Structures
Arrays allow us to group together information of one consistent data type. But what if we wanted to group information of various data types together into one variable? In this chapter, we will take a look at how we can group variables together and define our own data types!
Sometimes, it is beneficial to group together certain pieces of data that belong together. An example is a phone book entry that consists of a name and an associated phone number. Of course we could simply store all names in one array and all associated phone numbers in a second array, but it would be more convenient to have one array whose entries consist of records that contain both the name and the associated phone number. This is what structures are made for. They provide a fantastic way to define your own records in a single compact variable.