This version of file encoder and decoder program is based on the Huffman
coding method. It explicitly demonstrates the details of the files during the
encoding and decoding. The algorithm is encapsulated in a class
En_Decode by the standard C++ language. Here is a demonstration
project for the class.
Using the code
This class is implemented by standard C++, so it is very easy to use.
- Create an MFC application program as usual.
- Add the source file En_Decode.cpp and En_Decode.h to the project.
- Add the header file to your project by:
Define your own coder object, such as:
- Use the member function of the class to set the source file name and
destination encoded file name, then call
Encode() to encode the
In the same way, we can decode the encoded files to exactly the source
|Constructs a |
File Name Functions
|Set the input file name.|
|Set the output file name.|
|Get the ext name of the encoded file when
|Get the minimum frequency of the symbols in the source
|Get the maximum frequency of the symbols in the source
|Get the frequency value of a symbol in the source
|Get the number of active symbols in the source file.|
|Get the bytes number of the encoded file not including
|Get the length of the source file.|
|Get the average code length of the encoded file.|
|Get the entropy of the source file.|
Derek Lakin for his help with
CTabCtrlSSL in the demo
Contacting the Authors
This is the first time I share my code here. It is done in a hurry, so
exception handling is ignored. Any one who is interested in it can enhance it
freely, and please let me know about any improvement, thanks!
I am a junior student in Huangzhong University of Science and Technology,
China. I am interested in C++ and MFC, and any coding project. I am glad to
share my codes here with any one, though it is not that good.
Please contact me via email (email@example.com).
I am a junior student in Huangzhong University of Science and Technology, China. I am interested in C++ and MFC, and any coding project.
I am glad to share my codes here with any one, though it is not that good. Please contact me via email (firstname.lastname@example.org).