Sample code for 30+ languages & platforms
Unicode C++

bz2 Compress File

Compress a file to the bz2 file format.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkBz2W.h>

void ChilkatSample(void)
    {
    bool success = false;

    //  This example requires the Chilkat API to have been previously unlocked.
    //  See Global Unlock Sample for sample code.

    CkBz2W bz2;

    //  Compress the file qa_data/hamlet.xml to create qa_output/hamlet.bz2
    success = bz2.CompressFile(L"qa_data/hamlet.xml",L"qa_output/hamlet.bz2");
    if (success != true) {
        wprintf(L"%s\n",bz2.lastErrorText());
        return;
    }

    wprintf(L"Success.\n");
    }