Sample code for 30+ languages & platforms
C

bz2 Compress File

Compress a file to the bz2 file format.

Chilkat C Downloads

C
#include <C_CkBz2.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkBz2 bz2;

    success = FALSE;

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

    bz2 = CkBz2_Create();

    //  Compress the file qa_data/hamlet.xml to create qa_output/hamlet.bz2
    success = CkBz2_CompressFile(bz2,"qa_data/hamlet.xml","qa_output/hamlet.bz2");
    if (success != TRUE) {
        printf("%s\n",CkBz2_lastErrorText(bz2));
        CkBz2_Dispose(bz2);
        return;
    }

    printf("Success.\n");


    CkBz2_Dispose(bz2);

    }