StrForeachPtrReverse
- Macro
- October 8, 2025
Table of Contents
StrForeachPtrReverse
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
Name | Direction | Description |
---|---|---|
str | in,out | Str to iterate over. |
chrptr | in | Name 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) {
WriteFmt("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);
- In
Str.c:528
:
if (VecLen(str) > 0) {
size_t total_len = 0;
StrForeachPtrReverse(str, ch_ptr) {
total_len += 1;
}