-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLog.c
More file actions
39 lines (37 loc) · 1.06 KB
/
Copy pathLog.c
File metadata and controls
39 lines (37 loc) · 1.06 KB
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
#include "Log.h"
#include "canva.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int WriteLog(char *texte) {
FILE *fichier = fopen("Log.txt", "a");
if (fichier == NULL) {
printf("Erreur d'ouverture du fichier.\n");
return 1;
}
time_t now = time(NULL);
struct tm *tm_now = localtime(&now);
char s_now[20];
strftime(s_now, sizeof s_now, "%H:%M:%S", tm_now);
fprintf(fichier, "[%s] ", s_now);
fprintf(fichier, "%s", texte);
fprintf(fichier, "\n");
fclose(fichier);
return 0;
}
int Import_canva(Canva* canva){
FILE *fichier = fopen("Log.txt", "a");
if (fichier == NULL) {
printf("Erreur d'ouverture du fichier.\n");
return 1;
}
fprintf(fichier, "| id : %d\n", canva->id);
fprintf(fichier,"| nb_wall : %d\n", canva->nb_wall);
fprintf(fichier,"| id_next_canva :\n");
for(int i = 0; i < 4; i++) {
fprintf(fichier,"| | [%d] : %d\n", i, canva->id_next_canva[i]);
}
fprintf(fichier,"------------------\n");
fclose(fichier);
return 0;
}