Why do we leave some structure variables out of the curly brackets?

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).

Leave a Comment