0

How can I compress a file in c/c++? Since I want to devlop an application like WinZip / WinRAR. A simpler one.

Casper
  • 4,435
  • 10
  • 41
  • 72
user189352
  • 855
  • 4
  • 18
  • 26

4 Answers4

6

Take a look at zlib.

zooropa
  • 3,929
  • 8
  • 39
  • 61
4

You could give Huffman coding a try. Implementing Huffman coding is a pretty standard assignment in many CS programs.

From Wikipedia.

In computer science and information theory, Huffman coding is an entropy encoding algorithm used for lossless data compression. The term refers to the use of a variable-length code table for encoding a source symbol (such as a character in a file) where the variable-length code table has been derived in a particular way based on the estimated probability of occurrence for each possible value of the source symbol. It was developed by David A. Huffman while he was a Ph.D. student at MIT, and published in the 1952 paper "A Method for the Construction of Minimum-Redundancy Codes".

Kyle Walsh
  • 2,774
  • 4
  • 27
  • 25
2

Quick, simple, and easy to use ZIP compression utilities for C++:

Zip Utils - clean, elegant, simple, C++/Win32

Yana D. Nugraha
  • 5,069
  • 10
  • 45
  • 59
0

Take a look at gzip and bzip2. Both of these are widely used file compression algorithms that compress better than .zip does, however both of them are usually used only to compress a single file. In order to create archives, both gzip and bzip2 rely on a separate tar application.

If you would write a single application that could manage an archive containing gzipped/bzip2ed files, like winzip, that would indeed be simpler than raw gzip/bzip2.

Michael Dillon
  • 31,973
  • 6
  • 70
  • 106