struct book
{
char a[20];
int b;
};
struct sut
{
struct book w;
char name[20];
int age;
char id[20];
};
void print1(struct sut s)
{
printf(" %s %d %s %d %s \n", s.w.a, s.w.b, s.name, s.age, s.id);
}
void print2(struct sut* ps)
{
printf(" %s %d %s %d %s \n", ps->w.a, ps->w.b, ps->name, ps->age, ps->id);
}
//结构体
int main()
{
struct sut s = { { "自卑与超越", 53 }, "加德勒", 70, "213414" }; //定义结构体类型变量-初始化
//printf(" %s %d %s %d %s \n", s.w.a, s.w.b, s.name, s.age, s.id);
struct sut* ps = &s;
//printf(" %s %d %s %d %s \n", ps->w.a, ps->w.b, ps->name, ps->age, ps->id);
print1(s); //操作符输出方式
print2(&s); //指针指向
return 0;
}
03-11
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-03
3316
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-12
5171
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-22
3564
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)