The definition of a struct type variable is the same as that of other types of variables, but because the struct type needs to be defined in advance, the definition of the type variable of the struct body increases the flexibility by a total of three forms, each of which is described as follows:
1 Define the structure body type and then define the structural body type variables:
struct STU/* Define student structure type */
{
Char name[20]; /* Student Name */
char sex; /* Gender */
Long num; /* School Number */
float score[3]; /* Test results for three subjects */
};
struct Stu student1,student2;/* define struct type variable */
struct Stu Student3,student4;
With this struct type, you can define more of the struct type variable.
2 Define the structure body type and define the struct type variable:
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 of the struct type variable.
3) Direct definition of struct type variables:
struct
{
Char name[20]; /* Student Name */
char sex; /* Gender */
Long num; /* School Number */
float score[3]; /* Test results for three subjects */
} Person1,person2; /* Define the structure body type variable */
This definition method cannot be defined as a struct type variable, except for direct definition, because the struct body type cannot be logged.