UC3M

Telematic/Audiovisual Syst./Communication Syst. Engineering

Systems Architecture

September 2017 - January 2018

2.4.  Enumerations

This data type is used when some variables are required to store a reduced set of values not covered by any of the basic data types. Suppose that an application has to store the type of connection available in a device and must have one of the values GPRS, Wifi, Bluetooth or none. C allows to define a data type that can only store these values using the keyword enum as follows:

enum type_of_connection { GPRS, Wifi, Bluetooth, None};

From this definition on, there exists a new data type enum type_of_connection that can be used as any other data type:

enum type_of_connection connection_type;
connection_type = GPRS;
connection_type = Bluetooth;