#include <stdio.h>
struct Stu
{
char name[20];
int age;
double score;
};
struct Book
{
char name[20];
float price;
char id[30];
};
int main()
{
struct Stu s = { "张三",20,85.5 };//结构体创建和初始化
printf("1: %s %d %lf\n", s.name, s.age, s.score);//结构体变量.成员变量
struct Stu *ps = &s;
printf("2: %s %d %lf\n", (*ps).name, (*ps).age, (*ps).score);
printf("3: %s %d %lf\n", ps->name, ps->age, ps->score);//结构体指针->成员变量
return 0;
}
04-12
642
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-03
195
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)