Enumeration of the actual meaning of the meaning of Chinese is not much similar to the place, and it is easy to remind people of the poor lift.
After you've learned the basics, you're done with a few basic data types, huh?
The poor lift ... Yuck, enumerations and structs are similar in structure
struct stuent { int age ; float height; };
enum { FIR, SCD, THD};
But many different, as follows
1, the definition of a struct is defined as a data type , and then a struct variable is declared , the struct variable itself can only be assigned to another struct variable, and two structure variables must be the same structure, but the structure variable Variables within the range can be assigned. And the identifier used by the struct variable declaration does not occupy the space of the identifier of the variable , but it takes up a space with the common body, enumeration, and struct.
struct student Amy; int Amy =3;p rintf ("", Amy.age, Amy);
This is possible.
Enumerations also define a data type , but the declared enumeration variable has little resemblance to the struct variable. An enumeration variable is an integer variable, or it can be assigned a value (this differs from Baidu)
The identifier used by the enumeration variable declaration takes up space for the identifier of the variable . It may be that the storage class will overwrite, and the same storage class would conflict (usually, the code block will give me an error).
2, the member of an enumeration can only be an integer variable, so there is no need to declare the data type of the member, but the struct needs to be declared because the member of the struct can be a variable, an array, a pointer, a struct, an enumeration variable, or a common body.
3, enumerations, structs are defined data types, but structs are not actually useful after they are defined, only after declaring struct-body variables.
The identifier used by its members after the enumeration is defined takes up space for the identifier of the variable . And even if the enumeration variable is not defined, it can be used as a constant when its members are taken out.
4, the function of the structure in C language is not on the structure variables, but the internal members of the structure variables, the structural variables have little effect.
Enumerations are mostly enumerated constants, but variables can still be used when a common variable is available.
The "C" enumeration, and the differences between enumerations and struct bodies