main.c
1.92 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include "arbre.h"
int main (int argc,char *argv[]){
system("clear");
FILE* dico = NULL;
printf("==============================================\n");
if(argc >1){
printf("chargement de votre dictionnaire \n");
printf("nom: %s\n",argv[1]);
dico=fopen(argv[1],"r");
}
// else dico=fopen("words-no-accents","r");
if(dico == NULL){
// return EXIT_FAILURE;
printf("chargement du dictionnaire par default\n");
printf("nom du dico: words-no-accents\n");
dico=fopen("words-no-accents","r");
} //File is not readable
struct dico *mondico=malloc(sizeof(struct dico));
charger_dico(dico,&mondico);
// affiche_dico(mondico);
fclose(dico);
printf("==============================================\n\n\n");
char mot[]="zombie";
char mot2[]="chaine";
mot_existe(mondico->alpha[calculcase('r')],"rerere",0);
mot_existe(mondico->alpha[calculcase(mot[0])],mot,0);
mot_existe(mondico->alpha[calculcase(mot2[0])],mot2,0);
// printf("1: %s:%d \n",mot,mot_existe(mondico->alpha[calculcase(mot[0])],mot,0));
// printf("2: %s:%d \n",mot2,mot_existe(mondico->alpha[calculcase(mot2[0])],mot2,0));
FILE* fichier_utilisateur = NULL;
if(argc >2){
printf("Analyse de votre fichier \n");
fichier_utilisateur=fopen(argv[2],"r");
printf("Fin Analyse de votre fichier \n");
}
if (fichier_utilisateur!=NULL){
printf("analyse en cours\n");
int juste=0;
int faux=0;
analyse_fichier(fichier_utilisateur,mondico,&juste,&faux);
printf("juste:%d \n",juste);
printf("faux:%d \n",faux);
}
printf("fin programme \n");
free_dico(mondico);
if (fichier_utilisateur!=NULL){
fclose(fichier_utilisateur);
}
return 0;
}