Thread: how to compresss file

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    2

    how to compresss file

    write a simple compression program inc that can be used to compress the input file,given that all characters are ascii letters from a-z or A-Z or contains space and dots(.).
    please reply ASAP..

  2. #2
    Registered User
    Join Date
    Mar 2009
    Posts
    399
    A simple compression algorithm is RLE encoding.

    http://en.wikipedia.org/wiki/Run-length_encoding

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    RLE works poorly on written text, as most of the time, there is no more than two letters in a row that are the same. Since RLE builds on storing count and what to repeat, it doesn't work well when there aren't long sequences of items that are the same.

    A better method would be for example
    • Huffman coding.
      • LZW
      • ZIP
    • Bytepair


    All of these are based on "replacing the existing item with a shorter one". Bytepair can probably [for many instances] also be modified such that it is "text only" by using unusual/unused printable characters for the replacement.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  3. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  4. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM