Hi,
The code below is an example from my C book, which displays "Ace of Spades" using three different ways given the struct.
Just wondering. which way is the best and why?
Thank you.
Code:
#include <stdio.h>
struct card
{
char *face;
char *suit;
};
int main()
{
struct card aCard;
struct card *cardPtr;
aCard.face = "Ace";
aCard.suit = "Spades";
cardPtr = &aCard; /* assign address of aCard to cardPtr */
printf( "%s%s%s\n%s%s%s\n%s%s%s\n", aCard.face, " of ", aCard.suit,
cardPtr->face, " of ", cardPtr->suit,
( *cardPtr ).face, " of ", ( *cardPtr ).suit );
printf("\n");
return 0;
}