We have already seen how to access individual elements within a structure with dot (.) notation, or, if we have a pointer to the structure, with the arrow (->) notation. To access an array element with a structure, we would use the same notation for individual elements and simply add array notation ([]), as follows:
Shuffled aShuffled;
Shuffled* pShuffled = &aShuffled;
aShuffled.numDealt = 0;
aShuffled.bIsShuffled = false;
for( int i = 0 , i < kCardsInDeck; i++ )
aShuffled.shuffled[i] = NULL;
pShuffled->numDealt = 0;
pShuffled->bIsShuffled = false;
pShuffled->shuffled[i] = NULL;
We have declared a deck structure,aShuffled, and a pointer to a deck structure,pShuffled, initializing it to the address ofaDeck. The next three statements access each element of aShuffledusing dot (.) notation. The last three statements access each element of pShuffledusing arrow (->) notation.
We can now consider...