struct tm tm1,tm2;// tu ne dis pas quelle struct
puts(buf);// buf n'est pas connu
mktime(tm * tim); mktime(&tm1)// tu copies le prototype, là... et tim n'est pas connu
#define _XOPEN_SOURCE #include <stdio.h> #include <time.h> int main(void) { struct tm tm1,tm2; char buf1[255], buf2[255]; unsigned int diff; strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm1); strftime(buf1, sizeof(buf1), "%d %b %Y %H:%M", &tm1); puts(buf1); strptime("2001-11-13 05:31:01", "%Y-%m-%d %H:%M:%S", &tm2); strftime(buf2, sizeof(buf2), "%d %b %Y %H:%M", &tm2); puts(buf2); time_t t1 = mktime(&tm1); time_t t2 = mktime(&tm2); diff = t2 - t1; printf("La difference en secondes est: %u\n", diff); return 0; }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question#include <stdlib.h> #include #include <stdio.h> #include <string.h> int main(void) { char m[21] = {0}; char texte[] = "2001-11-13 18:31:01:25:50"; int ms = 0; int i = 0; memset(m, '0', 20); printf("%s\n", m); for (i = 20; texte[i] != ':'; ++i) m[i] = texte[i]; ms = atoi(m); printf("%s %i\n", m, ms); return 0; }