Getting total number of enum items
An enum
is a plain-old-C type, therefore it provides no dynamic runtime information.
One alternative is to use the last element of an enum to indicate the count:
typedef enum { Red, Green, Blue, numColors} Color;