Using pointers to structures
Before we finish with pointers, we need to expand the concept of a pointer pointing to a variable of an intrinsic type to that of a pointer pointing to a structure. We can then also expand the typedef
specifiers to structures to include the typedef
-defined pointers to structures.
Recall that a pointer points to the first byte of a target data type. We explored pointers to intrinsic types in Chapter 3, Working with Basic Data Types. Also, recall that a structure is a named location that holds a collection of named values. The structure as a whole is named, as are each of the member elements of that structure.
Once the structure type is defined, variables may be declared that are of that type. When a variable of any type is declared, the appropriate number of bytes is allocated in memory to store the values of that type. We can then access the member's structure elements directly...