How many values in an enum (Was: Enumerated types... what's the point?)

David Brown dave at motto.UUCP
Tue Mar 27 04:14:40 AEST 1990


In article <1425 at polari.UUCP> blm at 6sceng.UUCP (Brian Matthews) writes:
>ANSI enums, on the other hand, are
>little more than fancy #defines (although you can: a - insert new ones in the
>middle without renumbering the others by hand and b - have the compiler tell
>you how many there are.)

How do you get the compiler to tell you how many values an enumerated
type has?  Does this just refer to defining a final value, like

enum days_of_week = {SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
		     THURSDAY, FRIDAY, SATURDAY, N_DAYS_OF_WEEK };

or is there something more subtle?

 -----------------------------------------------------------------------------
|  David C. Brown	    |  uunet!mnetor!motto!dave			      |
|  Motorola Canada, Ltd.    |  416-499-1441 ext 3708			      |
|  Communications Division  |  "Of course I'm above average!  Who isn't?"     |
 -----------------------------------------------------------------------------



More information about the Comp.lang.c mailing list