How to use enumeration (enumeration type) in C language
(3) The default value of the first enumerated member is integer 0, and the values of the subsequent enumerated members are added with the previous member by 1. (4) You can set the values of enumerated members artificially, thus customizing an integer range. (5) Enumeration is an alternative to the preprocessing instruction #define. (6) The type definition is a semicolon; End. Define enum your numtype {ID 1,//If not specified, the first identifier is equal to the integer 0, followed by 1ID2, ID3=7, IDn//, and there is no comma after the last identifier}; //Note that this semicolon must be added to define the enumeration variable enum YOURENUMTYPE varname and assign varname = IDx to the enumeration variable; Give a complete example enumfruit {apple, pear, orange, peach, grape, banana}; Moon fruit myfruit = peach; 1 For example, students can be divided into college students, high school students and junior high school students. Enum can enumerate students {junior college, senior high school, junior high school}//Xiaoming is a college student = junior college; //Judge whether Xiaogang is a high school student.