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

Unzip Text File to String

See more Zip Examples

Demonstrates how to open a .zip and extract the 1st file (assuming it's a text file) to a string variable.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkZipW.h>
#include <CkZipEntryW.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.

    CkZipW zip;

    success = zip.OpenZip(L"qa_data/zips/EC16100.zip");
    if (success == false) {
        wprintf(L"%s\n",zip.lastErrorText());
        return;
    }

    // Get the 1st file in the .zip
    CkZipEntryW entry;
    success = zip.EntryAt(0,entry);
    if (success == false) {
        wprintf(L"%s\n",zip.lastErrorText());
        return;
    }

    const wchar_t *fileContents = entry.unzipToString(0,L"utf-8");
    wprintf(L"%s\n",fileContents);
    }