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
| #include "fonctions.h"
int main(int argc, char **argv)
{
NOEUD Table[MAX_CHAR];
unsigned char Set_Bit [8] = {128, 64, 32, 16, 8, 4, 2, 1};
short int x;
const char sr[]="cob.txt";
const char de[]="boc.txt";
char k;
NOEUD root;
NOEUD elem;
long int frequence;
FILE *src,
*des;
usage ();
if ((src=fopen(sr, "r")) == NULL){
printf ("%s not found!\n", sr);
return H_ERROR;
}
else
if ((des=fopen(de, "w")) == NULL){
printf ("can't create %s\n", de);
return H_ERROR;
}
if ((x = Alloc_Table (Table)) < 0){
printf("Error when mallocing the table...\n");
return H_ERROR;
}
frequence = Constrcut_Table (src, Table);
printf("tri de la table ...\n");
Sort_Table (Table);
printf("Done [%d]\n", frequence);
fputs ("goooooooundy", des);
/* Création de l'arbre de huffman */
int a;
for (a=0; a<MAX_CHAR; a++)
if (Table[a]->car >= 0)
printf("%c <> %d\n", Table[a]->car, Table[a]->occur);
printf("OK\n");
//Free_Table (Table);
fclose (src);
src = NULL;
fclose (des);
des = NULL;
return H_DONE;
} |
Partager