Huffman Coding Compressor built in C. It’s a neat tool to shrink text files by giving shorter codes to frequent characters. Think of it as a digital zipper for your files—lossless.
Huffman Coding is a classic algorithm that compresses data by assigning variable-length codes based on how often each character appears. More frequent = shorter code. This project lets you:
- Compress any file into a smaller binary version.
- Decompress it back to the original, bit for bit.
Perfect for text files with lots of repeating patterns!
Here’s the flow (Compression and Decompression) , visualized with a quick graph:
graph TD
A[Input File] --> B[Count Frequencies]
B --> C[Build Huffman Tree]
C --> D[Generate Codes]
D --> E[Bit-Packing]
E --> F[Write Compressed File]
Example
# Compress text.txt → compressed.huff
Operation: c
Input: text.txt
Output: compressed.huffgraph TD
A[Compressed File] --> B[Read Header]
B --> C[Rebuild Tree]
C --> D[Decode Bits]
D --> E[Write Original File]
Example
# Decompress compressed.huff → output.txt
Operation: d
Input: compressed.huff
Output: output.txtgcc huffman.c -o huffman./huffman-
c= Compress |d= Decompress -
Enter input file (must exist)
-
Enter output file (directory writable)
Sample Outputs [https://tanishx1.github.io/web-result/file%20compression/index.html]