Added book examples
This commit is contained in:
22
C19/enum_example.c
Normal file
22
C19/enum_example.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
enum DOW { sun, mon, tue, wed, thu, fri, sat } ;
|
||||
|
||||
// Main () - execution starts here
|
||||
int main (void)
|
||||
{
|
||||
enum DOW day;
|
||||
|
||||
/* Code that get a value for 'day' */
|
||||
day = tue;
|
||||
|
||||
switch (day)
|
||||
{
|
||||
case sun : printf ("Sunday\n") ; break ;
|
||||
case mon : printf ("Monday\n") ; break ;
|
||||
case tue : printf ("Tuesday\n") ; break ;
|
||||
/* etc. */
|
||||
}
|
||||
return (0); // Exit indicating success
|
||||
}
|
||||
Reference in New Issue
Block a user