1.
结构体
int float char short
double long
书:书名,书号,出版社,作者,定价
人: 名字,年龄,性别
struct结构 结构体
2.
//创建了一个自定义的类型
struct book
{
//结构体成员(变量)
char name[20];
char id[20];
int price;
};
int main()
{
int num = 10;
//结构体变量名.成员名
struct book b = {"C语言","c20220510",30};
struct book* pb = &b;
//结构体指针->成员名
printf("书名:%sn", pb->name);
printf("书号:%sn", pb->id);
printf("价格:%dn", pb->price);
//结构体变量名.成员名
//printf("书名:%sn", (*pb).name);
//printf("书号:%sn", (*pb).id);
//printf("价格:%dn", (*pb).price);
//printf("书名:%sn", b.name);
//printf("书号:%sn", b.id);
//printf("价格:%dn", b.price);
return 0;
}



