-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtime.c
More file actions
49 lines (27 loc) · 650 Bytes
/
Copy pathtime.c
File metadata and controls
49 lines (27 loc) · 650 Bytes
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char *argv[])
{
int i = NULL;
char format[128];
time_t temps;
struct tm date;
FILE* fichier = NULL;
// On récupère la date et l'heure actuelles.
time(&temps);
date=*localtime(&temps);
// On remplit la chaîne avec le format choisi, puis on l'affiche.
strftime(format, 128, "%X", &date);
fichier = fopen ("time.txt", "w");
if(fichier != NULL)
{
for(i=0;i<8;i++)
{
fprintf(fichier, "%c", format[i]);
}
fclose(fichier);
}
puts(format);
return 0;
}