Skip to content
StrForeachPtrInRange

StrForeachPtrInRange

Description

Walk characters of str in the half-open range [start, end), binding chrptr to a pointer to the current character. Convenience wrapper around StrForeachPtrInRangeIdx. See VecForeachPtrInRange for the full SUCCESS/FAILURE contract.

Usage example (Cross-references)

Usage examples (Cross-references)
    // Test StrForeachPtrInRange macro
    bool test_str_foreach_ptr_in_range(void) {
        WriteFmt("Testing StrForeachPtrInRange\n");
        DefaultAllocator alloc = DefaultAllocatorInit();
        // Build a new string by iterating through a range of character pointers
        Str result = StrInit(&alloc);
        StrForeachPtrInRange(&s, chrptr, 0, 5) {
            // Append the character to the result string
            StrPushBackR(&result, *chrptr);
Last updated on