C Tutorial/Structure/structure pointer — различия между версиями
Admin (обсуждение | вклад) м (1 версия: Импорт контента...) |
|
(нет различий)
|
Версия 14:21, 25 мая 2010
Using the structure member and structure pointer operators
#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;
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 );
return 0;
}
Ace of Spades Ace of Spades Ace of Spades