Skip to content

FOP Project | Winter 2024 - Using Huffman coding for compressing a text file with C

License

Notifications You must be signed in to change notification settings

ZahraAziziGit/compress-text-file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Compress Text File

This repository contains a C program for compressing and decompressing text files using Huffman coding. Huffman coding is a lossless data compression algorithm that assigns variable-length codes to input characters, with shorter codes assigned to more frequent characters.

Table of Contents

Features

  • Huffman Coding: Implements Huffman coding for compressing text files.
  • File Compression: Compresses input text files to reduce their size.
  • Decompression: Decompresses the compressed files to restore the original text. (⚠ currently doesn't work)

Installation

  1. Clone the repository:
    git clone https://github.com/ZahraAziziGit/compress-text-file.git
  2. Navigate to the project directory:
    cd compress-text-file
  3. Compile the C program:
    gcc compress.c -o run

Usage

Help Menu

To see the help menu, use the following command:

./run help

Compressing a Text File

To compress a text file, use the following command:

./run compress path/to/your/file.txt
  • compress: Command to compress the file.
  • path/to/your/file.txt: Path to the text file you want to compress.

Example:

./run compress file.txt

If your file is located in a different folder, for example on drive D: (windows)

./run compress D:\\path\\to\\your\\file.txt

Decompressing a Text File (⚠ currently doesn't work)

To decompress a text file, use the following command:

./run decompress path/to/your/file.txt
  • decompress: Command to decompress the file.
  • path/to/your/file.txt: Path to the compressed file you want to decompress.

Example:

./rune decompress file.txt

If your file is located in a different folder, for example on drive D: (windows)

./run decompress D:\\path\\to\\your\\file.txt

Project Structure

compress-text-file/
├── LICENSE.txt
├── README.md
└── compress.c
  • src/compress.c: The main program file that handles input arguments and compresses and decompresses the file

TODO

⬜ Implement decompression code.

⬜ Separate Huffman code from the main code.

⬜ Refactor compressing function.

⬜ Refactor decompressing function.

Contributing

Contributions are welcome! Please follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch:
    git checkout -b <feature-name>
  3. Make your changes and commit them:
    git commit -m 'Add some feature'
  4. Push to the branch:
    git push origin <feature-name>
  5. Open a pull request.

License

This project is licensed under the MIT License.


Thank you for checking out the Compress Text File project! If you have any questions or feedback, feel free to reach out.

Telegram

E-mail: azizi.zahra.tehran@gmail.com

About

FOP Project | Winter 2024 - Using Huffman coding for compressing a text file with C

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages