1、数据类型的定义
struct point {
int x;
int y;
};
2、结构体的定义
</pre></p><pre name="code" class="cpp">struct point {
int x;
int y;
};
struct point p1;
struct point是数据类型,故struct point p1就相当于int a,是一种定义。
同理:
structpoint {
int x;
int y;
} p1,p2;
3、结构体的声明
在.c文件中定义的结构体,可在.h文件中声明
struct point {
int x;
int y;
};
extern struct point p1;
4、结构体的初始化
struct point p1={100,200}