diff --git a/gestion_des_fichiers/bit_a_bit.c b/gestion_des_fichiers/bit_a_bit.c index 12118c6..e934421 100644 --- a/gestion_des_fichiers/bit_a_bit.c +++ b/gestion_des_fichiers/bit_a_bit.c @@ -2,20 +2,20 @@ #include #define BIN_MAX 8 -void binaire(unsigned int n, char s[]); +void int_to_bin(unsigned int n, char s[]); int main(int argc, char **argv){ FILE *file; char buffer; int cursor,c,i; - file=fopen("text.txt","rb"); + file=fopen("test.txt","rb"); char text_b[5][BIN_MAX+1]; i=0; // EOF : End Of File while((c=fgetc(file))!=EOF){ char sb[BIN_MAX+1]; - binaire(c,sb); - printf("%s\n",sb); + int_to_bin(c,sb); + printf("%d : %s\n",c,sb); } for(i=0;i<5;i++){ for(int j=0;j=0;k--){ s[k]= '0'; } -} \ No newline at end of file +} diff --git a/gestion_des_fichiers/bit_a_bit.exe b/gestion_des_fichiers/bit_a_bit.exe index 05e56fd..797028a 100644 Binary files a/gestion_des_fichiers/bit_a_bit.exe and b/gestion_des_fichiers/bit_a_bit.exe differ diff --git a/gestion_des_fichiers/bit_a_bit.o b/gestion_des_fichiers/bit_a_bit.o index 9402861..48dfa77 100644 Binary files a/gestion_des_fichiers/bit_a_bit.o and b/gestion_des_fichiers/bit_a_bit.o differ diff --git a/gestion_des_fichiers/test.txt b/gestion_des_fichiers/test.txt new file mode 100644 index 0000000..fe3a073 --- /dev/null +++ b/gestion_des_fichiers/test.txt @@ -0,0 +1 @@ +NULL \ No newline at end of file diff --git a/gestion_des_fichiers/text.txt b/gestion_des_fichiers/text.txt index 402476b..dadb807 100644 --- a/gestion_des_fichiers/text.txt +++ b/gestion_des_fichiers/text.txt @@ -1 +1 @@ -ABCDE \ No newline at end of file +NNN \ No newline at end of file diff --git a/main_compress.c b/main_compress.c index 6404a43..536b981 100644 --- a/main_compress.c +++ b/main_compress.c @@ -13,7 +13,7 @@ int main(int argc, char **argv){ const char *mode= "rb"; // Vérification de l'existance du second argument (Nom du fichier à compresser) printf("Argc : %d\n",argc); - if(argc != 2){ + if(argc == 2){ printf("\nErreur : Veuillez mettre en argument un nom de fichier à compresser (Ex: %s text.txt)\n",argv[0]); return -1; } @@ -23,10 +23,12 @@ int main(int argc, char **argv){ return -2; } printf("test\n"); - int *nb_char; - *nb_char=0; + int nb_char; + nb_char=0; + int *p; + p=&nb_char; Freq freq; - freq = freq_apparition(file, nb_char); + freq = freq_apparition(file, p); printf("hey"); return 0; }