C Game Dev Enum

- Related Questions & Answers
- Selected Reading
Dev C++ Game Programming
C Enumeration. Enum in C is a data type that contains fixed set of constants. It can be used for days of the week (SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY and SATURDAY), directions (NORTH, SOUTH, EAST and WEST) etc. The C enum constants are static and final implicitly. C Enums can be thought of as classes that have fixed. PlayerOptions enum - possible options on player's turn; PlayerInGameStatus enum - current player status (playing or standing) PlayerEndGameStatus enum - player status at the end of the game (winner, loser.) IPlayer's methods are called by the Game component to notify the player about events. The Game component contains.
Enumeration is a user defined datatype in C language. It is used to assign names to the integral constants which makes a program easy to read and maintain. The keyword “enum” is used to declare an enumeration.
Here is the syntax of enum in C language,
The enum keyword is also used to define the variables of enum type. There are two ways to define the variables of enum type as follows.
C++ Enum
Here is an example of enum in C language,
Example
C++ Enum Naming
Output
C++ Enum Count
In the above program, two enums are declared as week and day outside the main() function. In the main() function, the values of enum elements are printed.