Do C Enums Start at 0?

Do C Enums Start at 0?

4 Answers. Yes. Unless you specify otherwise in the definition of the enumeration, the initial enumerator always has the value zero and the value of each subsequent enumerator is one greater than the previous enumerator.

What is the starting value of enum in C?

If we do not explicitly assign values to enum names, the compiler by default assigns values starting from 0. For example, in the following C program, sunday gets value 0, monday gets 1, and so on.

Are enums 0 based?

An Enum is a value type and its default value (for example for an Enum field in a class) will be 0 if not initialized explicitly. Therefore you generally want to have 0 as an defined constant (e.g. Unknown).

Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.