Skip to content

StrCharPtrAt

StrCharPtrAt

Description

Get pointer to character at given index

Usage example (Cross-references)

Usage examples (Cross-references)
                if (VecLen(str) > 0 && *offset + 2 <= size) {
                    size_t idx = extract_u16(data, offset, size) % VecLen(str);
                    char  *ptr = StrCharPtrAt(str, idx);
                    (void)ptr; // Suppress unused variable warning
                }
    // Test StrCharPtrAt function
    bool test_str_char_ptr_at(void) {
        WriteFmt("Testing StrCharPtrAt\n");
    
        Str s = StrInitFromZstr("Hello");
        // 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