Summary
In this chapter, we learned about user-defined C structures. This is one of the most powerful ways of representing real-world objects in a cohesive and clear manner. First, we learned how to declare structures of our basic intrinsic types and custom types (enum
). Then, we explored how to directly access and manipulate the components of C structures. The only simple operation that we can perform on structures in toto is the assignment operator.
We also explored how to manipulate structures via functions that access structure components and manipulate either the individual components, the entire structure, or multiple structures at the same time. We then expanded on the concept of what can be in a structure by defining structures of other structures. Finally, we learned that while C is not an OO language, we saw how C structures are the stepping stone to languages that are OO.
You may have found that, while using enums and structs, having to remember to add those keywords...