From 76c9eef337dcfa819a35855432f3f69f61c6ad32 Mon Sep 17 00:00:00 2001 From: VIliam Date: Sun, 19 Jan 2025 20:40:43 +0100 Subject: [PATCH] skuska --- sk1/compressor.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sk1/compressor.c b/sk1/compressor.c index f7923e0..29d9da2 100644 --- a/sk1/compressor.c +++ b/sk1/compressor.c @@ -120,7 +120,7 @@ int compress_1(const char* input_file_name, const char* output_file_name) { unsigned char* data = read_file(input_file_name, &size); if (!data) return -1; - + HuffmanNode* root = build_huffman_tree(data, size); if (!root) { free(data); @@ -141,7 +141,14 @@ int compress_1(const char* input_file_name, const char* output_file_name) { return -1; } - fwrite(data, 1, size, output_file); + + + + + for (size_t i = 0; i < size; i++) { + fputs(codes[data[i]], output_file); + } + fclose(output_file); printf("Compressing using Huffman coding...\n");