#include <stdio.h>
#include <string.h>
struct book
{
char name[30];
short price;
};
int main()
{
struct book a = {"研究生录取通知书",10};
struct book* pb = &a;
printf("name of book = %s\n",pb->name);//用指针变量来找a的名字
printf("price of book = %d\n",pb->price);//用指针变量来找a的名字
printf("name of book = %s\n",a.name);//用‘.’来找a的名字
printf("price of book = %d\n",a.price);
printf("name of book = %s\n",(*pb).name);//(*pb)等价于结构体a
printf("price of book = %d\n",(*pb).price);
strcpy(a.name,"c++");
printf("%s\n",a.name);
return 0;
}
07-10
1886