All of the considerations we explored for enums equallyapply tostructs.We will go through each of them as they apply to structs.
Before we examine the use of typedef with structs, we must first complete the picture of using structs. In the last chapter, Chapter 9, Creating and Using Structures, we used structs by first defining them and then separately declaring variables of that type, as follows:
// First define a structured type.
struct Card { Face face; Suit suit; ... };
// Then declare variables of that type.
struct Card c1 , c2 , c3 , c4 , c5;
In the preceding code fragment, we have defined one type,struct Card. In a separate statement, five variables of that type are declared—c1,c2,c3, c4, andc5.
Another way to achieve the same result is to both define the structured type and declare variables of that type in one statement, as follows:
// Defining an structure and declaring...