You are mixing things up. A struct card
has the members face
and suit
. But there are three variables using the struct card
type, namely aCard, deck, cardPtr
.
Alternatively one could have written:
typedef struct {
char *face;
char *suit;
} Card;
Card aCard, deck[52], *cardPtr;
// or even
Card aCard;
Card deck[52];
Card *cardPtr;
For the typedef
have a look at: Why should we typedef a struct so often in C? (It goes into the typedef struct { ... } Foo;
vs struct Foo {...}
debate).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…