hi there.
could somebody tell me how to use fgets instead of scanf in the example below? thank you.
Code:
void read_date(int *yyyy, int *mm, int *dd) {
int i;
while(1) {
printf("Enter date (YYYY MM DD): ");
i = scanf("%d %d %d", yyyy, mm, dd);
if(i == 3) {
if((*yyyy < 1) || (*yyyy > 9999)) {
printf("YYYY must be between 0 and 9999\n");
continue;
}
if((*dd < 1) || (*dd > days_month[*mm-1])) {
printf("DD must be between 1 and %d for the month of %s\n", days_month[*mm-1], months[*mm-1]);
continue;
}
if((*mm < 1) || (*mm > 12)) {
printf("MM must be between 1 and 12\n");
continue;
}
} else {
continue;
}
break;
}
}
Code tags fixed by Hammer