diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..35b40e4 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +FLAGS= -Wall -Wextra + +all : projetfinal + +projetfinal: projetfinalaccent2.o main.o + gcc -c main.c projetfinalaccent2.c $(FLAGS) + + gcc main.o projetfinalaccent2.o -o projetfinal $(FLAGS) \ No newline at end of file diff --git a/fonctions.h b/fonctions.h new file mode 100644 index 0000000..b0d15cd --- /dev/null +++ b/fonctions.h @@ -0,0 +1,36 @@ +#include +#include +#include +#include + +#define A 256 + +struct node { + wchar_t lettre; + struct cell* listeFils; +}; + +struct cell { + struct node* arbre; + struct cell* arbreSuivant; +}; + +void ajout_tete(wchar_t, struct cell**); + +struct cell ** insertion(wchar_t, struct cell**); + +void initialisation_tab_arbre(struct node); + +int indice_lettre(struct node, wchar_t); + +void remplir_dico(FILE*, struct node); + +struct cell ** test_mot(wchar_t, struct cell**, int*); + +void correction_txt(FILE, struct node); + +void correction_mot(struct node); + +void desalocationArbre(struct cell**); + +void desalocationTableauArbre(struct node); \ No newline at end of file diff --git a/main.c b/main.c new file mode 100644 index 0000000..27cd9ea --- /dev/null +++ b/main.c @@ -0,0 +1,35 @@ +#include "fonctions.h" + +#define A 256 + +int main(int argc, char* argv[]) { + + + setlocale(LC_ALL, ""); + FILE* dico = NULL; + FILE* txt = NULL; + struct node tab_arbre[A]; + + if(argc>2) { + dico = fopen(argv[1], "r"); + txt = fopen(argv[2], "r"); + } + else { + dico = NULL; + txt = NULL; + } + if ((dico == NULL) || (txt == NULL)) { + wprintf(L"Erreur : il manque un ou plusieurs fichiers !\n"); + return 1; + } + initialisation_tab_arbre(tab_arbre); + remplir_dico(dico, tab_arbre); + + correction_txt(txt, tab_arbre); + correction_mot(tab_arbre); + desalocationTableauArbre(tab_arbre); + + printf("fini\n"); + + return 0; +} \ No newline at end of file diff --git a/projetfinalaccent2.c b/projetfinalaccent2.c index f67ccc1..103cbd5 100644 --- a/projetfinalaccent2.c +++ b/projetfinalaccent2.c @@ -3,17 +3,9 @@ #include #include -#define A 256 - -struct node { - wchar_t lettre; - struct cell* listeFils; -}; +#include "fonctions.h" -struct cell { - struct node* arbre; - struct cell* arbreSuivant; -}; +#define A 256 void ajout_tete(wchar_t elem, struct cell** pL) { struct cell* p; @@ -48,14 +40,16 @@ void initialisation_tab_arbre(struct node tab[]) { tab[i].lettre = '?'; tab[i+1].lettre = '!'; tab[i+2].lettre = '\''; - for(int j = 0; j <= 2; j++) { //Ajout des caractères de ponctuation par défaut + tab[i+3].lettre = '.'; //Ajout des caractères de ponctuation par défau + tab[i+4].lettre = ':'; + tab[i+5].lettre = ';'; + for(int j = 0; j <= 5; j++) { tab[i+j].listeFils = NULL; insertion('\0', &(tab[i+j].listeFils)); } } -int indice_lettre(struct node tab_arbre_prcp[], wchar_t lettre) -{ +int indice_lettre(struct node tab_arbre_prcp[], wchar_t lettre) { int i = 0; while(i >= 0 && i < A){ if(lettre == tab_arbre_prcp[i].lettre ){ @@ -72,7 +66,6 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { int cptmot = 0, indice = 0; wchar_t motLu[50]; while(fwscanf(fd, L"%ls", motLu)==1) { - //wprintf(L"mot lu : %ls\n", motLu); int estUneLettre = 1; int i = 0; cptmot += 1; @@ -135,7 +128,6 @@ void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) { localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils; } else if((motLu[0] < 'A') || (motLu[0] > 'z')) { - printf("jsuisla\n"); indice = indice_lettre(tab_arbre_prcp, motLu[0]); localisationArbre = &tab_arbre_prcp[indice].listeFils; if(indice == -1) { @@ -212,7 +204,7 @@ void desalocationArbre(struct cell** pL) { free(*pL); } -void desalocationTableauArbre(struct node tab_arbre[]){ +void desalocationTableauArbre(struct node tab_arbre[]) { int i = 0; for(wchar_t u = 'a'; u < A; u++) { desalocationArbre(&tab_arbre[i].listeFils); @@ -220,34 +212,3 @@ void desalocationTableauArbre(struct node tab_arbre[]){ } } -int main(int argc, char* argv[]) { - - - setlocale(LC_ALL, ""); - FILE* dico = NULL; - FILE* txt = NULL; - struct node tab_arbre[A]; - - if(argc>2) { - dico = fopen(argv[1], "r"); - txt = fopen(argv[2], "r"); - } - else { - dico = NULL; - txt = NULL; - } - if ((dico == NULL) || (txt == NULL)) { - wprintf(L"Erreur : il manque un ou plusieurs fichiers !\n"); - return 1; - } - initialisation_tab_arbre(tab_arbre); - remplir_dico(dico, tab_arbre); - //for(int i = 0; i < A; i++) wprintf(L"%lc\n", tab_arbre[i].lettre); - correction_txt(txt, tab_arbre); - correction_mot(tab_arbre); - desalocationTableauArbre(tab_arbre); - - printf("fini\n"); - - return 0; -} diff --git a/projetfinalaccent2.exe b/projetfinalaccent2.exe index 2d6bdd4..b0e0ea8 100644 Binary files a/projetfinalaccent2.exe and b/projetfinalaccent2.exe differ -- libgit2 0.21.2