Define a struct type, using typedef
,
for a date.
A date consists of a month, a day name, and
an integer from 0 to 31.
Use an enum
with a typedef
for the month
and for the day name.
Write a function to set the values of a date and to print a date. Do some easy error checking in the set function, but don't bother writing error messages or returning an error code.
/* declare the enums */ /* declare the Date type */ /* function to print a Date */ void printDate( Date *date ) {...} /* function to set a Date */ void setDate( Date *date ) {...} int main() { /* declare and initialize two Dates */ Date birthday, duedate; /* set the dates */ setDate( &birthday, 22, wed, feb ); setDate( &duedate, 13, fri, aug ); /* print values of both Dates */ printDate( birthday ); printDate( duedate ); return 0; }