Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

📦 RLE Compressor / Decompressor (C)

A simple Run-Length Encoding (RLE) tool written in C that can compress and decompress data using standard input/output.


🧠 What it does

This program performs:

🔹 Compression

Converts repeated characters into:

(character, count)

Example:

AAABBBCC → A3B3C2

But internally stored as binary pairs:

A 3 B 3 C 2

🔹 Decompression

Reconstructs original text from encoded format.


⚙️ Features

  • Simple RLE compression
  • Fast character-based processing
  • Works with stdin/stdout (pipes supported)
  • Lightweight C implementation

📂 Files

rle.c        → main source code
README.md    → documentation

🚀 Compilation

Use GCC to compile:

gcc rle.c -o rle

▶️ Usage

🔹 Compress

./rle compress < input.txt > output.bin

🔹 Decompress

./rle decompress < output.bin > output.txt

🧾 How it works

Compression logic:

  • Reads characters one by one

  • Counts consecutive repeating characters

  • Outputs:

    character + count
    

Decompression logic:

  • Reads pairs:

    character, count
    
  • Repeats character count times


⚠️ Limitations

  • Works only with binary-safe input (no formatting guarantees for text view)
  • Not efficient for non-repetitive data

📌 Example

Input:

AAAAABBBCCDAA

Compressed output (binary form):

A 5 B 3 C 2 D 1 A 2

Decompressed output:

AAAAABBBCCDAA

🧠 Concepts used

  • Run-Length Encoding (RLE)
  • Character stream processing
  • Standard I/O in C
  • Command-line arguments

👨‍💻 Author

0x7byte


📈 Future improvements

  • 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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages