Bonjour,
Il y a la fonction localtime() qui convertit un time_t en une structure tm dans laquelle on trouve les données nécessaires pour formater une chaîne.
#include <stdio.h>
#include <time.h>
void main()
{
time_t horloge1 = time(0);
struct tm* horloge2;
horloge2 = localtime(&horloge1);
printf("Il est %02d:%02d:%02d\n"
,horloge2->tm_hour,horloge2->tm_min,horloge2->tm_sec);
}
et dans time.h :
struct tm
{
int tm_sec; /* seconds after the minute - [0,59] */
int tm_min; /* minutes after the hour - [0,59] */
int tm_hour; /* hours since midnight - [0,23] */
int tm_mday; /* day of the month - [1,31] */
int tm_mon; /* months since January - [0,11] */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday - [0,6] */
int tm_yday; /* days since January 1 - [0,365] */
int tm_isdst; /* daylight savings time flag */
};
Jean-François