Enumerated Types

An enumerated type (declared with enum) has values limited to a specified set. If the enum declaration does not specify any values, QuickC assigns sequential integers to the enumeration identifiers beginning at zero.

The example below assigns the values of 0, 1, and 2 to the enumeration identifiers zero, one, and two, respectively. It also creates an enumerated type small_numbers that can be used to declare other variables.

/* Enumerated data type */

enum small_numbers {zero, one, two};

/* Variable my_numbers is of type small_numbers */

enum small_numbers my_numbers;

The following example explicitly assigns values to the enumeration identifiers:

/* Enumerated data type */

enum even_numbers { two = 2, four = 4, six = 6 };