Assignment #5
Huffman Code

Huffman Code is a method of file compression using variable length codes for compression, and decompression.

In this assignm you are given a file called huffman.dat. This file contains information about characters and weights. Each line of the file consists of two fields. First the ascii value of the character, and second the weight of the character. The only characters that are valid in our assignment are UPPER case letters, and the the newline character (\n).

Your program should be named huffman.

Your program must be able to compress, and decompress a file. There should only be one program to run though, so the compression and decompressin must be determined from an inline parameter to your c program. To compress a file the character c should be used, and do extract or decompress a file the character x should be used. Also the program should take the name of the file in through the inline parameters and the name of the output file.

Inline parameters in C are pulled in through arguments to main. Here is an Example Program that demonstrates inline parameters. The program just takes and prints all of the parameters given to it. So if I run the program:

I would get the results

Notice that arg #0 is the name of the program, and the reset of the arguments are the parameters givin to the program.

The output of the compressed file should be in ascii with only 1's and 0's present. And only 3 output codes per line. Therefor the input of a compressed file will be of this same format, and the output should be that of the original file. The reason for having the output of the compressed file as ascii is to be able to view the output. Otherwise it would be dificult to view. Also this elievates the problem of bit-twiddling in your program.


You are the 16th Person to Access this Page