/* * Napi¹te testovací program "enumtest.c", kde ve funkci main - nejdøíve naètìte ze std vstupu jednu hodnotu a vytisknìte - potom vypisujte mìsíce do výstupního souboru dokud nedojde k chybovému ukonèení programu */ int main(void) { /* test - NEMÌNIT! */ char *l = setlocale(LC_ALL,"cs_CZ.iso-8859-2"); if(l==NULL) Error("setlocale: Nelze nastavit èeskou lokalizaci\n"); enum months m; m = ReadMonth(); // ète mìsíc PrintMonthShort(m); // tiskne krátké jméno printf("\n"); PrintMonth(m); // tiskne dlouhé jméno printf("\n\n"); for( m = Leden; m < 15; m++ ) { // úmyslná chyba PrintMonthShort(m); printf("\n"); } return 0; }
/* prints the calendar for the month and year, whose first day starts on startWday (0 = Sunday, 1 = Monday, .. 6 = Saturday; and the month has daysInMonth days. This is just a printing routine... it does not know how many days the month has, nor does it know what day of the week first day is. */ void PrintGenericCalendar(int month, int year, int startWday, int daysInMonth){ printf("\n "); PrintMonth(month);/*prints this month*/ printf(" %d\n", year);/*prints this year*/ printf(" Sun Mon Tue Wed Thu Fri Sat\n");/*print headline*/ int i,j; for(i=0;i<=5;i++){/*i=number of row*/ /*j=date,while colum=1~6*/ for(j=1+(7*i-startWday);j<7+(7*i-startWday);j++){ if(j<=0) printf("%4c", ' ');/*(j=date)<=0,print null*/ else if(j<=daysInMonth) printf("%4d", j);/*daysInMonth>=(j=date)>0,print j*/ else printf("%4c", ' ');/*(j=date)>daysInMonth,print null*/ } if(j>daysInMonth) break; printf("%4d\n", j);/*j=date,while colum=7*/ } };