Chapter 14

Structures, the Multivariable

IN THIS CHAPTER

check Creating structures

check Declaring structure variables

check Assigning values to a structure variable

check Building structure arrays

check Putting one structure inside another

Individual variables are perfect for storing single values. When you need more of one type of a variable, you declare an array. For data that consists of several different types of variables, you mold the variable types into something called a structure. It’s the C language’s method of creating a variable buffet.

Hello, Structure

I prefer to think of the C language structure as a multivariable, or several variables rolled into one. You use structures to store or access complex information. That way, you can keep various int, char, float variables, and even arrays, all in one neat package.

Introducing the multivariable

Some things just belong together — like your name and address or your bank account number and all the money that’s supposedly there. You can craft such a ...

Get C Programming For Dummies, 2nd Edition 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.