bonjour,
je fais une appli qui va gérer des délais, exemple tu n'as pas fait la vaisselle depuis 28 jours ou depuis 1 mois 3 jours et 2 heures
je coince sur les calculs, j'ai essayé difftime le format de mes variables ne lui convient pas (structures tm)
voici mon code de début...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
#include <stdio.h>
#include <time.h>
 
int main(void)
{
    time_t secondes;
    struct tm ancienMoment;
	struct tm actuelMoment;
	struct tm duree;
 
    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=8;
	ancienMoment.tm_year=2013;
    printf("%02d/%02d/%04d ; %02d:%02d:%02d\n", actuelMoment.tm_mday+1, 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+1, ancienMoment.tm_mon+1, ancienMoment.tm_hour, ancienMoment.tm_min, ancienMoment.tm_sec);
 
		//printf("Tu n'as pas fait la vaisselle depuis %f secondes.", difftime(ancienMoment, actuelMoment)); ca ne marche pas et les 2 variables ancienMoment, actuelMomentne sont pas reconnues
 
	return 0;
 
}
d'autre part j'aimerais convertir dans les différents formats permettant de simplifier les calculs puis remettre en structure tm... c'est idiot ? j'ai raison ?
merci de votre aide
le papy prog qui fait joujou à l'ordi
Amicalement