diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..600d2d3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode \ No newline at end of file diff --git a/arbre_de_codage/arbre_binaire.c b/arbre_de_codage/arbre_binaire.c index bae65d8..e932c74 100644 --- a/arbre_de_codage/arbre_binaire.c +++ b/arbre_de_codage/arbre_binaire.c @@ -41,9 +41,9 @@ bool est_arbre_vide(arbre a) return (a == NULL) ; } -arbre creer_feuille(Elt e) +arbre creer_feuille(Elt e, int p) { - return creer_arbre(e, creer_arbre_vide(), creer_arbre_vide()) ; + return creer_arbre_huffman(e, p, creer_arbre_vide(), creer_arbre_vide()) ; } bool est_feuille(arbre a) diff --git a/arbre_de_codage/arbre_binaire.h b/arbre_de_codage/arbre_binaire.h index 01de6e5..fffb9be 100644 --- a/arbre_de_codage/arbre_binaire.h +++ b/arbre_de_codage/arbre_binaire.h @@ -1,7 +1,7 @@ #ifndef __ARBRE_BINAIRE__ #define __ARBRE_BINAIRE__ -typedef char Elt; +typedef int Elt; typedef int bool; struct znoeud { Elt elt ; @@ -19,7 +19,7 @@ arbre fils_droit(arbre a); Elt racine(arbre a); bool est_arbre_vide(arbre a); -arbre creer_feuille(Elt e) ; +arbre creer_feuille(Elt e, int p) ; bool est_feuille(arbre a) ; #endif diff --git a/main_compress.c b/main_compress.c index 6fe70e4..97006cc 100644 --- a/main_compress.c +++ b/main_compress.c @@ -2,30 +2,36 @@ #include "arbre_de_codage/arbre_binaire.c" #include "arbre_de_codage/liste.c" -Freq freq_apparition(FILE *file); +Freq freq_apparition(FILE *file, int *nb_char); arbre huffman(arbre H, Freq L[]); // main_compress.c [nom_du_fichier_a_compresser] int main(int argc, char **argv){ FILE *file; + const char *filename = argv[1]; + const char *mode= "rb"; // Vérification de l'existance du second argument (Nom du fichier à compresser) + printf("Argc : %d",argc); if(argc != 2){ printf("\nErreur : Veuillez mettre en argument un nom de fichier à compresser (Ex: %s text.txt)\n",argv[0]); return -1; } // Vérification de l'ouverture du fichier en mode lecture binaire !! FONCTION A MODIFIER - else if(file=fopen(argv[1],'rb')){ - printf("\nErreur : Fichier %s inexistant\n",argv[1]); + else if(!(file=fopen(filename,mode))){ + printf("\nErreur : Fichier %s inexistant\n",filename); return -2; } - - - + int *nb_char; + *nb_char=0; + Freq freq; + freq = freq_apparition(file, nb_char); + printf("hey"); + return 0; } -Freq freq_apparition(FILE *file){ +Freq freq_apparition(FILE *file, int *nb_char){ Freq text; text = creer_liste_vide(); int c; @@ -34,11 +40,11 @@ Freq freq_apparition(FILE *file){ text=incrementer(c,text); } else{ - + text=ajouter(1,c,text); } - + *nb_char++; } - + return text; } arbre huffman(arbre H, Freq L[]){ @@ -46,7 +52,5 @@ arbre huffman(arbre H, Freq L[]){ Création de l'arbre de codage de Huffman en considérant une liste avec les fréquences d'apparition des caractères ordonnée croissante */ int i; - - printf(L[]->nb); - printf(L[]->lettre); + return H; } \ No newline at end of file diff --git a/main_compress.exe b/main_compress.exe new file mode 100644 index 0000000..8dd7cf8 Binary files /dev/null and b/main_compress.exe differ diff --git a/main_compress.o b/main_compress.o new file mode 100644 index 0000000..81ce5ff Binary files /dev/null and b/main_compress.o differ diff --git a/start.bat b/start.bat new file mode 100644 index 0000000..aeb0e0e --- /dev/null +++ b/start.bat @@ -0,0 +1,2 @@ +main_compress.exe gestion_des_fichiers/text.txt +PAUSE \ No newline at end of file