Code will not compile, what am I doing wrong? // Program to determine tomorrow\'
ID: 3667008 • Letter: C
Question
Code will not compile, what am I doing wrong?
// Program to determine tomorrow's date #include #include struct date { int month; int day; int year; }; struct dateAndTime { Date sdate; struct time stime; }; typedef struct date Date; //now whenever you call 'struct date' you can just call 'Date' // Function to calculate tomorrow's date Date dateUpdate (Date today) { Date tomorrow; if ( today.day < numberOfDays(today) ) { tomorrow.day = today.day + 1; tomorrow.month = today.month; tomorrow.year = today.year; } else if ( today.month == 12 ) { // end of year tomorrow.day = 1; tomorrow.month = 1; tomorrow.year = today.year + 1; } else { // end of month tomorrow.day = 1; tomorrow.month = today.month + 1; tomorrow.year = today.year; } return tomorrow; } // Function to find the number of days in a month int numberOfDays (Date d) { int days = 0; bool isLeapYear(d) (struct date d); const int daysPerMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; if ( isLeapYear(d) && d.month == 2 ) {days = 29;} else {days = daysPerMonth[d.month - 1];} return days; } // Function to determine if it's a leap year bool isLeapYear (Date d) { bool leapYearFlag; if((d.year%4==0 && d.year % 100 !=0) || d.year % 400 == 0){ leapYearFlag = true; // It's a leap year } else { leapYearFlag = false; // Not a leap year } return leapYearFlag; } struct dateAndTime clockKeeper (struct dateAndTime dateTime) { dateTime.stime = timeUpdate(dateTime.stime); if (dateTime.stime.hours == 0 && dateTime.stime.minutes == 0 && dateTime.stime.seconds == 0) { dateTime.sdate = dateUpdate(dateTime.sdate); } return dateAndTime; } int main () { struct date dateUpdate (struct date today); struct date thisDay, nextDay; printf ("Enter today's date (mm dd yyyy): "); scanf ("%d %d %d", &thisDay.month, &thisDay.day, &thisDay.year); struct time timeUpdate(struct time now); struct time currentTime, nextTime; printf("Enter time (hh:mm:ss): "); scanf("%d:%d:%d", & currentTime.hour, ¤tTime.minutes, & currentTime.seconds); struct dateAndTime dt; dt.sdate = thisday; dt.stime = currentTime; dt = clockKeeper(dt); nextday = dt.sdate; nextTime = dt.stime; }
Explanation / Answer
Not Declaring the headder files.