Simple structural Body
struct student{
Char name[20]; can be scanf or directly assigned to a value
* If you use char *name when using scanf, no memory is received
Long ID;
int age;
float height;
};
A struct can only declare variables that cannot be assigned an initial value.
struct student Zhangsan;
struct Student Zhangsan = {"Xiaowang", 2000002,20,180.5};
The structure is accessed using "." : Xiaowang.name
typedef
typedef struct student{
Char name[20]; Cannot use char *name when using scanf without memory reception
Long ID;
int age;
float height;
}student;//typedef take an alias for an existing type
Student Zhangsan;
Student Zhangsan = {"Xiaowang", 2000002,20,180.5};
If you do not add a typedef:
struct student{
Char name[20]; Cannot use char *name when using scanf without memory reception
Long ID;
int age;
float height;
}student;//student is a variable.
struct-Body pointer
Student *s;
If *name is a string s->name = "Xiaowang";
If name[] is an array to receive strcpy (S->name, "Xiaowang");
S->age = 23;
Student *s[5]; Each piece has the address of the structure.
Student XW ={"Xiaowang", 2345,23,164.3};
S[0] =&xw; Each of the struct pointer arrays contains an address, and if you do not give him a memory address, its value is empty and cannot be directly assigned.
S[0]->age = 20;
struct array
Student array[5] ={};
strcpy (Array[0].name, "Xiaowang");
Array[0].age = 23;
1211.1--Structural Body