A simple Run-Length Encoding (RLE) tool written in C that can compress and decompress data using standard input/output.
This program performs:
Converts repeated characters into:
(character, count)
Example:
AAABBBCC → A3B3C2
But internally stored as binary pairs:
A 3 B 3 C 2
Reconstructs original text from encoded format.
- Simple RLE compression
- Fast character-based processing
- Works with stdin/stdout (pipes supported)
- Lightweight C implementation
rle.c → main source code
README.md → documentation
Use GCC to compile:
gcc rle.c -o rle./rle compress < input.txt > output.bin./rle decompress < output.bin > output.txt-
Reads characters one by one
-
Counts consecutive repeating characters
-
Outputs:
character + count
-
Reads pairs:
character, count -
Repeats character
counttimes
- Works only with binary-safe input (no formatting guarantees for text view)
- Not efficient for non-repetitive data
AAAAABBBCCDAA
A 5 B 3 C 2 D 1 A 2
AAAAABBBCCDAA
- Run-Length Encoding (RLE)
- Character stream processing
- Standard I/O in C
- Command-line arguments
0x7byte
- File-based compression (fopen/fwrite version)
- Support for larger counts (>255)
- Combine with Huffman or LZ77 for better compression
- Add header format for safer decoding