Struct type variable definition
Struct type variables have the same definitions as other types of variables. However, the struct type needs to be defined in advance, so the definition form of struct type variables increases flexibility, there are three forms, which are described as follows:
1) first define the struct type, and then define the struct type variable:
Struct stu/* define the student struct type */
{
Char name [20];/* Student name */
Char sex;/* Gender */
Long num;/* student ID */
Float score [3];/* score of the three subjects */
};
Struct stu student1, student2;/* defines the struct type variable */
Struct stu student3, student4;
With this struct type, you can define more variables of this struct type.
2) define the struct type and define the struct type variables at the same time:
Struct data
{
Int day;
Int month;
Int year;
} Time1, time2;
You can also define the following variables:
Struct data time3, time4;
With this struct type, you can also define more variables of this struct type.
3) directly define struct type variables:
Struct
{
Char name [20];/* Student name */
Char sex;/* Gender */
Long num;/* student ID */
Float score [3];/* score of the three subjects */
} Person1, person2;/* defines the struct type variable */
This definition method cannot record the struct type. Therefore, except for direct definition, this struct type variable cannot be defined. I have been using C for the first time for five years.