0
I saw that has a function in the team. h calculating difference between date I went on the site Documentation link time. h, did not quite understand how to perform this calculation, for example wanted to calculate the difference between the date 12/09/2018 and 12/09/1997
Code provided by the page
#include <stdio.h> /* printf */
#include <time.h> /* time_t, struct tm, difftime, time, mktime */
int main ()
{
time_t now;
struct tm newyear;
double seconds;
time(&now); /* get current time; same as: now = time(NULL) */
newyear = *localtime(&now);
newyear.tm_hour = 0;
newyear.tm_min = 0;
newyear.tm_sec = 0;
newyear.tm_mon = 0;
newyear.tm_mday = 1;
seconds = difftime(now, mktime(&newyear));
printf ("%.f seconds since new year in the current timezone.\n", seconds);
return 0;
}
And you’re having some trouble?
– Maniero
Cool actually I did not understand how to calculate the difference of the dates I entering the dates via keyboard
– rafael marques