我只是在看Deitel的这个例子:
#include <stdio.h>
struct card {
char *face;
char *suit;
};
int main( void )
{
struct card aCard;
struct card *cardPtr;
aCard.face = "Aces";
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
);
system("pause");
return 0;
}
我看到有一个指向 char 的指针,但从没想过你可以使用char *
...保存字符串
问题是:这里的内存是如何处理的,因为我没有看到任何类似char word[50]
.