Skip to content

StrForeachPtr

Description

Walk each character of str forward, binding chrptr to a pointer to the current character. Use when the body needs to mutate characters in place. See VecForeachPtr for the full SUCCESS/FAILURE contract.

Usage example (Cross-references)

Usage examples (Cross-references)
    // Test StrForeachPtr macro
    bool test_str_foreach_ptr(void) {
        WriteFmt("Testing StrForeachPtr\n");
        DefaultAllocator alloc = DefaultAllocatorInit();
        // Build a new string by iterating through each character pointer
        Str result = StrInit(&alloc);
        StrForeachPtr(&s, chrptr) {
            // Append the character (via pointer) to the result string
            StrPushBackR(&result, *chrptr);
Last updated on