/* File: mycal7.c Step 7 in writing my version of the calendar program. This version is compiled seperately from functions taken from the textbook's calendar program. */ #include #include "genlib.h" #include "simpio.h" #include "calendar.h" main() { int year, month, i ; int start, this_month_days ; /* get year from user */ printf("year =? ") ; year = GetInteger() ; printf("\n") ; /* January 1900, starts on Monday */ start = 1 ; for (i = 1900; i < year ; i++) { start = AddDay(start, YearDays(i)) ; } /* Print a calendar for year month. */ for (month = 1 ; month <= 12 ; month++) { printf("%s %d\n", MonthName(month), year) ; printf(" S M Tu W Th F S\n") ; this_month_days = MonthDays(month, year) ; PrintOneMonth(start, this_month_days) ; printf("\n") ; start = AddDay(start, this_month_days) ; } }