Struct
struct string
{
char name[8];
int age;
char sex[2];
} person,person1[20];
struct string
{
char name[8];
int age;
char sex[2];
} ;
struct string person;
struct string person1[20];
两个写法等价。写在**“struct string{}”** 和 “;” 之间的相当于一个变量。
typedef
typedef struct STU{
char name[20];
int age;
char sex;
} Student;
有了这个typedef之后,student就不是一个对象了,是一个别名。即以下两种定义等价:
struct STU stu1;
Student stu1;
带数组的:
//顶点表头
typedef struct VHead {
PtrToVNode firstVer;
int EarlistTime;
}AdjList[MaxVertexNum];
//图
struct GNode {
int Vnum, Enum;
AdjList G;
//AdjList相当于一个长度为MaxVertexNum的数组,数据类型为struct VHead
};