Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Can enum type in c language input its value with input statements such as SCANF?
Can enum type in c language input its value with input statements such as SCANF?
1, yes, in C, enum type is actually int type, but not in C++.

In C language, it can be like this:

Enumeration colors (red; green; blue);

Enumerate color a;

scanf("%d ",& ampa);

If the input is 0, it corresponds to red, 1 corresponds to green and 2 corresponds to blue.

2. Enumeration is a data type in computer programming language. Enumeration: In practical problems, the values of some variables are limited in a limited range. For example, there are only seven days in a week, only twelve months in a year, and a class has six classes a week. It is obviously inappropriate to describe these quantities as integers, characters or other types. To this end, the C language provides a type called "enumeration". All possible values are listed in the definition of "enumeration" type, and the values of variables described as "enumeration" type cannot exceed the defined range. Note that the enumeration type is a basic data type, not a constructed type, because it cannot be decomposed into any basic types.