void printCalendar(int day, int year) { //prints each month. also, keeps track of what day of the week the next month will start on int numOfDays; int k = 0; for (k = 0; k<12; k++) { numOfDays = printMonthName(k,year); //gets the number of days in the month that is about to be printed day = printMonth(day,numOfDays); } }
char printMonth(int year, int month, int startDay){ int dayCount, i; dayCount = printMonthName(year, month); for(i = 1; i < startDay; i++) printf(" "); //space to staring point for(i = 1; i <= dayCount; i++){ printf("%3d ", i); if(startDay == 7){ //rollover to a new line printf("\n"); startDay = 0; } startDay++; } //Evenly space all months if(startDay != 1)printf("\n\n"); else printf("\n"); return startDay; }