Structure: A collection with a value that cannot be typed
Union: Similar to structure, but sharing a storage space (only one member can be stored at a time)
Enumeration: is a type of shaping
Declaration of struct structure body
Structure Tag Declaration
struct part { int number; char name[256];};struct part part1;//不能去掉struct//也可以像下面的方式声明变量struct part { int number; char name[256];}part1, part2;
Using the definition of a struct type
//声明part类型的结构体typedefstruct { int number; char name[256];}part;part part1;//声明变量
struct as a parameter of a function
//打印结构体void printf_part(struct part p) { printf("number is %d", p.number); printf("name is %s", p.name);}
Declaration of an array of structures
struct part parts[100];//声明能装100个part类型变量的数组
Joint
Union and struct-like use, except that each union variable has a common storage space, changing the value of one variable will variable the value of other variables.
Just change the struct to union.
Enumeration
Statement:
enumflag { false0, true};
enum { false,//枚举内的值会默认从0开始 true}flag;
"C-language summary" struct, union, enumeration