From: Leandro Lucarella Date: Mon, 21 Jun 2004 22:04:18 +0000 (+0000) Subject: Hago que imprima bpb al terminar :) X-Git-Tag: svn_import~98 X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/commitdiff_plain/2ab683271e74b5cffc675da7f5b9e4b34bb4047c?ds=inline;hp=5bf62ffb7054c30de3b8bbf3d18f420f731eb765 Hago que imprima bpb al terminar :) --- diff --git a/src/jacu.c b/src/jacu.c index fc4188f..fe94998 100644 --- a/src/jacu.c +++ b/src/jacu.c @@ -8,6 +8,8 @@ #include #include +long get_file_size(const char* filename); + int main(int argc, char* argv[]) { int cflag = 0; @@ -117,6 +119,9 @@ int main(int argc, char* argv[]) /* borro el temporal */ unlink("tmp.comp"); + + /* Muestro bpb */ + printf("Comprimido a %.04f bpb.\n", get_file_size(argv[optind+1])*8.0/get_file_size(argv[optind])); return i; } @@ -158,3 +163,15 @@ int main(int argc, char* argv[]) return 0; } + +long get_file_size(const char* filename) +{ + FILE* file; + long file_size; + + if (!(file = fopen(filename, "ab"))) return -1; + file_size = ftell(file); + fclose(file); + return file_size; +} +