Code:
#include<iostream.h>
#include<time.h>
int main()
{
// Set first date (22/2/1998):
struct tm date1_struct={0};
time_t date1_t;
date1_struct.tm_year = (1998 - 1900);
date1_struct.tm_mon = 2;
date1_struct.tm_mday = 22;
date1_t = mktime(&date1_struct);
// Set second date (1/3/1998):
struct tm date2_struct={0};
time_t date2_t;
date2_struct.tm_year = (1998 - 1900);
date2_struct.tm_mon = 3;
date2_struct.tm_mday = 1;
date2_t = mktime(&date2_struct);
// Display difference:
cout << "Difference in days: "
<< (((difftime(date2_t, date1_t)/60)/60)/24) << endl;
return 0;
}
returns a value of 10 instead of 7.... I have a funny feeling I am missing something very small here.....
Thanks for the help!!
Yes, this is homework!!