您的位置:首页 > 其它

结构体和typedef

2016-05-08 02:45 281 查看
c语言的结构体使用方法:

1. 第一种方法:
声明
struct Person {
float weight;
float height;
};
使用
struct Person lloyd;
lloyd.weight = 60;
lloyd.height = 175;
2. 第二种方法,使用typedef
声明
typedef struct {
float weight;
float height;
} Person;
使用
Person lloyd; //不用写struct了


typedef其他用法
如:
typedef char Line[81]; //定义Line为char[81]的数组
Line haha, hehe; //haha 与 hehe都是char[81]类型
上面代码相当于:
char haha[81];
char hehe[81];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  结构体 typedef