So I have this for my main function.
Code:
int main(void)
{
int year;
int month;
int first_day;
do{
printf("Enter a month (1 - 12): ");
scanf("%d", &month);
} while (month < 1 || month > 12);
do{
printf("Enter a year (1978 - 3000): ");
scanf("%d", &year);
} while (year < 1978 || year > 3000);
first_day = first_day_year(year);
leapyear(year);
calendar(month, year, first_day);
printf("\n");
return 0;
}
How can I revise the part where the program asks for a number from 1-12 (for the months) and 1978-3000 (for the year) without it going through an infinite loop when the user enters letters (a-z, A-Z) and other characters? It should only accept the specified numbers.