1. Structure declaration:
struct struct body name {
type specifier member name;
...
type specifier member name;
};
Structs, arrays are constructed from basic data types, and arrays are data types constructed from the same basic data types, and structs can be constructed from different basic data types. Structs are more flexible than arrays.
Access struct member: struct variable. struct Member name
The assignment of struct variables: STU1 = STU2 is directly assigned;
Based on this feature, the overall assignment of the array can be accomplished with the help of the struct.
The memory allocation principle of the structure body:
1. Open space according to the largest data type of the member of the struct, and continue to open up space according to the maximum number of bytes when the allocated space is insufficient;
2. Allocate according to the second largest data type of the number of bytes in the struct member;
3. If the allocation is surplus, no longer occupied.
Structure function:
1. Custom data types (constructed types) that can be used to define variables
2. Struct is a large container, flexible than array, can store variables of different data types
C language Seventh: structural body