Add Beginning of Compress Function

This commit is contained in:
NyxiumYuuki 2019-12-07 21:54:27 +01:00
parent ab7f63447a
commit d89bc3383e
No known key found for this signature in database
GPG key ID: 03E8F3CF3183323A
7 changed files with 24 additions and 17 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.vscode

View file

@ -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)

View file

@ -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

View file

@ -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;
}

BIN
main_compress.exe Normal file

Binary file not shown.

BIN
main_compress.o Normal file

Binary file not shown.

2
start.bat Normal file
View file

@ -0,0 +1,2 @@
main_compress.exe gestion_des_fichiers/text.txt
PAUSE