1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include <stdio.h>
#include <time.h>
int main(void)
{
time_t secondes;
time_t duree_t;
struct tm ancienMoment;
struct tm actuelMoment;
struct tm duree;
//double duree_t;
time(&secondes);
actuelMoment =*gmtime(&secondes);
//ancienMoment =*localtime(&secondes);
ancienMoment.tm_hour=10;
ancienMoment.tm_mday=10;
ancienMoment.tm_min=5;
ancienMoment.tm_sec=0;
ancienMoment.tm_mon=12;
ancienMoment.tm_year=2013-1900;
printf("%02d/%02d/%04d ; %02d:%02d:%02d\n", actuelMoment.tm_mday, actuelMoment.tm_mon+1,actuelMoment.tm_year+1900, actuelMoment.tm_hour, actuelMoment.tm_min, actuelMoment.tm_sec);
printf("%02d/%02d ; %02d:%02d:%02d\n", ancienMoment.tm_mday, ancienMoment.tm_mon+1, ancienMoment.tm_hour, ancienMoment.tm_min, ancienMoment.tm_sec);
printf("Pas fait la vaisselle pendant %f secondes.\n", difftime( mktime(&actuelMoment), mktime(&ancienMoment) ));
duree_t = difftime( mktime(&actuelMoment), mktime(&ancienMoment) );
printf("Pas fait la vaisselle pendant %f secondes.", duree_t);
duree = mktime(&duree_t);
printf("Pas fait la vaisselle pendant %f secondes.", &duree.tm_sec);
getchar();
//system("PAUSE");
return 0;
} |
Partager