enum dow { sun, mon, tue, wed, thu, fri, sat };
Given this type definition, you can create variables of this type:
enum dow today;
Then, you can assign values to today
:
today = tue;
Note that C allows you to assign any integer values to an enum
type,
which can lead to much abuse. As a programming practice, you should only
use the symbolic terms defined for an enumerated type. In our example,
this means we should only use sun
to sat
when we specify
values in expressions involving a enum dow
type.