StrForeachPtrReverse

Table of Contents

StrForeachPtrReverse

Description

Iterate over each character pointer chrptr of the given Str str in reverse order. This is a convenience macro that iterates backward using an internally managed index and provides a pointer to each character. The variable chrptr is declared and defined by the underlying VecForeachPtrReverse macro as a pointer to the character type.

Parameters

NameDirectionDescription
strin,outStr to iterate over.
chrptrinName of the pointer variable to be used which will point to the current character during iteration. The type of chrptr will likely be a pointer to the character type used by the Str implementation (e.g., char*).

Usage example (Cross-references)

    // Test StrForeachPtrReverse macro
    bool test_str_foreach_ptr_reverse(void) {
    printf("Testing StrForeachPtrReverse\n");
    
    Str s = StrInitFromZstr("Hello");
    size char_count = 0;
    
    StrForeachPtrReverse(&s, chrptr, {
    // Append the character (via pointer) to the result string
    StrPushBack(&result, *chrptr);

Share :