He is quering how to start print the month.
Altough the previous solution have interesting links, to be more specific he needs a function to peek the day of week for the first day of the month, this is commonly called Zeller congruence. There are many versions of this algorithm around.
The simplest version is the Michael Keith and Tom Craver algorithm:
int dayofweek(int d, int m, int y)
{
return (d+=m<3?y--:y-2,23*m/9+d+4+y/4-y/100+y/400)%7
}
This return a number in the range [0, 6], where 0=sunday and 6=friday.
in this case your calendar should print:
void printmonth(int m, int y, int lastday)
{
int day = dayofweek(1, m, y);
printf ("SU MO TU WE TH FR SA\n");
for (int i=0; i<day;> printf(" - ");
for (day = 1; day<=lastday; day++)
{
int dow = dayofweek(day, m, y);
if (!dow)
putchar('\n');
printf ("%2i ", day);
}
putchar('\n');
}
It has to be invoked as:
printmonth(mo, ye, numOfDays(mo, ye));