I\'m currently reading about enums in C. I understand how they work, but can\'t figure out situations where they could be useful. Can you give me some simple examples where the
Sometime you want to express something that is finite and discrete. An example from the GNU C Programming tutorial are compass directions.
enum compass_direction
{
north,
east,
south,
west
};
Another example, where the ability of enums to correspond to integers comes in handy, could be status codes.
Usually you start the OK code with 0, so it can be used in if constructs.