September 1998
Intermediate to advanced
848 pages
20h 13m
English
You can use the enumerated type to declare symbolic names to represent integer constants. It is a common C extension that has been incorporated into the ANSI C standard. By using the enum keyword, you can create a new "type" and specify the values it may have. (Actually, enum constants are type int, so they can be used wherever you would use an int.) The purpose of enumerated types is to enhance the readability of a program. The syntax is similar to that used for structures. For example, you can make these declarations:
enum spectrum {red, orange, yellow, green, blue, violet};
enum spectrum color;
The first declaration establishes spectrum as a type name, and the second declaration makes color a variable of that type. The ...
Read now
Unlock full access