00160129
rsSimonin
creation main.c
|
1
2
3
4
5
6
|
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include "arbre.h"
|
35bdc271
rsimonin
affichage
|
7
8
|
int main (int argc,char *argv[]){
system("clear");
|
1e85143f
rsimonin
modif_affichage
|
9
10
11
12
13
14
15
|
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf("\nBonjour et bienvenue dans le projet de Programmation Avancée IMA 3\n\n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
printf("\nAppuyez sur ENTREE pour continuer...\n");
getchar();
|
35bdc271
rsimonin
affichage
|
16
|
FILE* dico = NULL;
|
1e85143f
rsimonin
modif_affichage
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
char mot_dico[20]; //opti
char mot_fichier[20];
if(argc <2){
printf("Vous n'avez pas entrée de dictionnaire ainsi que de fichier\n");
printf("Veuillez entrez votre nom de dictionnaire\n");
scanf("%s",mot_dico);
printf("\n\n");
printf("Veuillez entrez votre nom de fichier\n");
scanf("%s",mot_fichier);
printf("\n\n");
}
else if(argc <3){
printf("Vous n'avez pas entrée de fichier\n");
printf("Veuillez entrez votre nom de fichier\n");
scanf("%s",mot_fichier);
printf("\n\n");
}
printf("==================================================================\n");
|
35bdc271
rsimonin
affichage
|
39
40
41
42
43
|
if(argc >1){
printf("chargement de votre dictionnaire \n");
printf("nom: %s\n",argv[1]);
dico=fopen(argv[1],"r");
}
|
1e85143f
rsimonin
modif_affichage
|
44
45
46
47
48
|
else {
printf("chargement de votre dictionnaire \n");
printf("nom: %s\n",mot_dico);
dico=fopen(mot_dico,"r");
}
|
35bdc271
rsimonin
affichage
|
49
50
51
|
// else dico=fopen("words-no-accents","r");
if(dico == NULL){
|
1e85143f
rsimonin
modif_affichage
|
52
|
printf("Nous avons pas compris votre demande.\nNous vous chargeons le dictionnaire par default\n");
|
35bdc271
rsimonin
affichage
|
53
54
|
printf("nom du dico: words-no-accents\n");
dico=fopen("words-no-accents","r");
|
1e85143f
rsimonin
modif_affichage
|
55
56
|
}
|
35bdc271
rsimonin
affichage
|
57
|
|
00160129
rsSimonin
creation main.c
|
58
|
struct dico *mondico=malloc(sizeof(struct dico));
|
35bdc271
rsimonin
affichage
|
59
60
61
|
charger_dico(dico,&mondico);
// affiche_dico(mondico);
fclose(dico);
|
1e85143f
rsimonin
modif_affichage
|
62
|
printf("==================================================================\n\n\n");
|
35bdc271
rsimonin
affichage
|
63
|
|
1e85143f
rsimonin
modif_affichage
|
64
65
66
67
|
printf("\nAppuyez sur ENTREE pour continuer...\n");
getchar();
getchar();
|
00160129
rsSimonin
creation main.c
|
68
|
|
35bdc271
rsimonin
affichage
|
69
70
|
// 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));
|
00160129
rsSimonin
creation main.c
|
71
|
|
35bdc271
rsimonin
affichage
|
72
|
FILE* fichier_utilisateur = NULL;
|
1e85143f
rsimonin
modif_affichage
|
73
|
printf("##################################################################\n");
|
35bdc271
rsimonin
affichage
|
74
|
if(argc >2){
|
1e85143f
rsimonin
modif_affichage
|
75
|
printf("Ouverture de votre fichier: %s \n",argv[2]);
|
35bdc271
rsimonin
affichage
|
76
|
fichier_utilisateur=fopen(argv[2],"r");
|
1e85143f
rsimonin
modif_affichage
|
77
78
79
80
81
82
83
84
85
|
printf("Fermeture de votre fichier \n");
}
else {
printf("Ouverture de votre fichier: %s \n",mot_fichier);
fichier_utilisateur=fopen(mot_fichier,"r");
printf("Fermeture de votre fichier \n");
}
if (fichier_utilisateur==NULL){
printf("Nous avons pas reussi à ouvrir le fichier\n");
|
35bdc271
rsimonin
affichage
|
86
|
}
|
1e85143f
rsimonin
modif_affichage
|
87
88
89
|
printf("##################################################################\n");
printf("\nAppuyez sur ENTREE pour continuer...\n");
getchar();
|
35bdc271
rsimonin
affichage
|
90
91
|
if (fichier_utilisateur!=NULL){
|
1e85143f
rsimonin
modif_affichage
|
92
93
|
printf("\n\n¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤\n");
printf("analyse en cours\n\n");
|
35bdc271
rsimonin
affichage
|
94
95
96
|
int juste=0;
int faux=0;
analyse_fichier(fichier_utilisateur,mondico,&juste,&faux);
|
1e85143f
rsimonin
modif_affichage
|
97
98
99
100
|
printf("Votre fichier contient %d de mots, dont %d justes et %d faux.\n",juste+faux,juste,faux);
printf("¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤\n");
printf("\nAppuyez sur ENTREE pour continuer...\n");
getchar();
|
35bdc271
rsimonin
affichage
|
101
102
|
}
|
1e85143f
rsimonin
modif_affichage
|
103
|
printf("\n\n\nLe programme est fini, vous pouvez relancer une execution\nCommande: ./executable NOM-DICO NOM-FICHIER\n\nA bientôt\n");
|
00160129
rsSimonin
creation main.c
|
104
|
free_dico(mondico);
|
35bdc271
rsimonin
affichage
|
105
106
107
108
|
if (fichier_utilisateur!=NULL){
fclose(fichier_utilisateur);
}
|
00160129
rsSimonin
creation main.c
|
109
110
|
return 0;
}
|