struct

作者: zeiii | 来源:发表于2018-11-14 18:10 被阅读0次

结构体Struct

就是一个组装过程,可以在主函数内也可以在外完成组装。最初可以每次定义结构都这么写

Struct {
int a;
int b;
} s;

然后可以对s.a,s.b赋值。
也可以先组装命名后再复用,大括号后的分号不能省。

struct S{
int a;
int b;
};
struct S s;
struct不能省

用typedef把整个结构体重命名后就可以直接S s来定义了。

typedef struct S{
int a;
int b;
} S;

这个时候给结构体的命名也可以丢掉了

typedef struct {
int a;
int b;
} S;

相关文章

网友评论

      本文标题:struct

      本文链接:https://www.haomeiwen.com/subject/abajfqtx.html