C · Quickstart

Quickstart

6.0.0-rc.1 · cb8d956a

Ask your coding agent about this page, or add the docs server to it

curl -s 'https://www.unum.cloud/docs/stringzilla/c/quickstart.md' | claude -p "How would this fit my code?"

This program finds the first match of a needle through the sz_find_best dispatch point, with the capabilities this CPU runs:

#include <stdio.h>
#include <stringzilla/stringzilla.h>

int main(void) {
    sz_capability_t capabilities = sz_cap_serial_k;
    sz_capabilities_enabled_cpu(&capabilities); // what this CPU runs and this binary holds
    char const haystack[] = "the quick brown fox";
    sz_cptr_t match = NULL;
    sz_status_t status = sz_find_best(haystack, sizeof(haystack) - 1, "brown", 5, &match, capabilities, NULL);
    if (status != sz_success_k || !match) return 1; // a pointer to the match, or NULL
    printf("found at %d\n", (int)(match - haystack)); // 10
    return 0;
}