Skip to content

StrCharPtrAt

Description

Pointer to the character at idx. Caller must ensure idx < length.

Parameters

Name Direction Description
str in String to query.
idx in Index in [0, length).

Usage example (Cross-references)

Usage examples (Cross-references)
    
        for (u64 i = 0; i < StrLen(&result) / 2; i++) {
            char *lhs = StrCharPtrAt(&result, i);
            char *rhs = StrCharPtrAt(&result, StrLen(&result) - 1 - i);
            char  tmp = *lhs;
        for (u64 i = 0; i < StrLen(&result) / 2; i++) {
            char *lhs = StrCharPtrAt(&result, i);
            char *rhs = StrCharPtrAt(&result, StrLen(&result) - 1 - i);
            char  tmp = *lhs;
            *lhs      = *rhs;
    // Test StrCharPtrAt function
    bool test_str_char_ptr_at(void) {
        WriteFmt("Testing StrCharPtrAt\n");
        DefaultAllocator alloc = DefaultAllocatorInit();
        // Access character pointers at different indices
        // Now using the fixed StrCharPtrAt macro
        char *p0 = StrCharPtrAt(&s, 0);
        char *p1 = StrCharPtrAt(&s, 1);
        char *p2 = StrCharPtrAt(&s, 2);
        // Now using the fixed StrCharPtrAt macro
        char *p0 = StrCharPtrAt(&s, 0);
        char *p1 = StrCharPtrAt(&s, 1);
        char *p2 = StrCharPtrAt(&s, 2);
        char *p3 = StrCharPtrAt(&s, 3);
        char *p0 = StrCharPtrAt(&s, 0);
        char *p1 = StrCharPtrAt(&s, 1);
        char *p2 = StrCharPtrAt(&s, 2);
        char *p3 = StrCharPtrAt(&s, 3);
        char *p4 = StrCharPtrAt(&s, 4);
        char *p1 = StrCharPtrAt(&s, 1);
        char *p2 = StrCharPtrAt(&s, 2);
        char *p3 = StrCharPtrAt(&s, 3);
        char *p4 = StrCharPtrAt(&s, 4);
        char *p2 = StrCharPtrAt(&s, 2);
        char *p3 = StrCharPtrAt(&s, 3);
        char *p4 = StrCharPtrAt(&s, 4);
    
        // Check that the pointers are correct
Last updated on