| types/days-1.c - En enumeration type enum days og en funktion next_day_of. | Lektion 8 - slide 8 : 29 Program 1 |
enum days {sunday, monday, tuesday, wednesday, thursday,
friday, saturday};
/* Tedious function. An alternative version appears later in this lecture */
enum days next_day_of(enum days d){
enum days next_day;
switch (d){
case sunday: next_day = monday;
break;
case monday: next_day = tuesday;
break;
case tuesday: next_day = wednesday;
break;
case wednesday: next_day = thursday;
break;
case thursday: next_day = friday;
break;
case friday: next_day = saturday;
break;
case saturday: next_day = sunday;
break;
}
return next_day;
}