e2104.cpp

来自「游戏开发数据结构Data Structures for Game Program」· C++ 代码 · 共 47 行

CPP
47
字号
// =======================================================
//  Chapter 21, Example 4
//  Huffman Decompression
// =======================================================
#include <stdlib.h>
#include <stdio.h>
#include <iostream.h>
#include <string.h>
#include "Array.h"
#include "Huffman.h"



void main()
{
    typedef unsigned char uchar;
    Array<uchar> uncompressed( 1 );
    Huffman<uchar, 255> compressed;

    // filename
    char dataname[80];
    char treename[80];

    // get the file names
    cout << "Enter tree file name: ";
    cin >> treename;
    cout << "Enter data file name: ";
    cin >> dataname;


    // load the tree
    compressed.LoadTree( treename );

    // load the data
    compressed.LoadData( dataname );

    // decompress the data
    compressed.Decompress( uncompressed );


    // chop off the ending of the file name
    dataname[ strlen(dataname) - 5 ] = 0;
    uncompressed.WriteFile( dataname );

    cout << "Decompressed to " << dataname << endl;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?