C语言结构体(struct)的几种定义方式

1.struct结构体名

{

//成员表列

};

2.struct

{

//成员表列

}变量名;

结构体变量要和结构体同时定义。

3.struct结构体名

{

//成员表列

}变量名;

结构体变量与结构体同时定义。

4.typedef struct 结构体名 

{

//成员表列

};

此时结构体没有别名,定义变量形式为 struct 结构体名 变量名。

5.typedef struct 结构体名 

{

//成员表列

}别名;

定义结构体变量可以用别名直接定义,也可以按照方式4。

6.typedef struct

 {

//成员表列

}别名;

直接用别名定义结构体变量。

猜你喜欢

转载自blog.csdn.net/baidu_41774120/article/details/82789146