Simulation of File Compression Algorithms Gaming Project in C++

Explanation

  1. Class Definition (RunLengthEncoder):
    • Public Methods:
      • compress(const std::string& input):
        • Compresses the input string using Run-Length Encoding (RLE).
        • Iterates through the string, counting consecutive occurrences of each character.
        • Constructs a compressed string in the format: character followed by the count.
        • Returns the compressed string.
      • decompress(const std::string& compressed):
        • Decompresses a string that was compressed using RLE.
        • Parses the compressed string to reconstruct the original string.
        • Returns the decompressed string.
  2. main Function:
    • Prompts the user to enter a string for compression.
    • Uses the RunLengthEncoder class to compress the input string and prints the result.
    • Then decompresses the compressed string to verify the accuracy and prints the decompressed string.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top