Skip to content

StrCharAt

Description

Access the character at idx by value. 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)
        // after it. Otherwise insert at the start of the content.
        size insert_pos = content_start;
        if (content_len > 0 && (StrCharAt(o, content_start) == '-' || StrCharAt(o, content_start) == '+')) {
            insert_pos += 1;
        }
            if (split > 0) {
                for (i64 i = 0; i < split; i++) {
                    if (!StrPushBackR(&result, StrCharAt(&digits, i))) {
                        goto fail;
                    }
    
                for (u64 i = (u64)split; i < StrLen(&digits); i++) {
                    if (!StrPushBackR(&result, StrCharAt(&digits, i))) {
                        goto fail;
                    }
    
        for (idx = 0; idx < StrLen(str); idx++) {
            hash ^= (u64)(unsigned char)StrCharAt(str, idx);
            hash *= 1099511628211ULL;
        }
        }
    
        if (StrLen(decimal) > 0 && StrCharAt(decimal, 0) == '+') {
            start = 1;
        }
            LOG_FATAL("Invalid arguments");
        }
        if (StrLen(digits) > 0 && StrCharAt(digits, 0) == '+') {
            start = 1;
        }
        }
    
        if (StrLen(binary) >= 2 && StrCharAt(binary, 0) == '0' &&
            (StrCharAt(binary, 1) == 'b' || StrCharAt(binary, 1) == 'B')) {
            start = 2;
    
        if (StrLen(binary) >= 2 && StrCharAt(binary, 0) == '0' &&
            (StrCharAt(binary, 1) == 'b' || StrCharAt(binary, 1) == 'B')) {
            start = 2;
        }
        }
    
        if (StrLen(octal) >= 2 && StrCharAt(octal, 0) == '0' &&
            (StrCharAt(octal, 1) == 'o' || StrCharAt(octal, 1) == 'O')) {
            start = 2;
    
        if (StrLen(octal) >= 2 && StrCharAt(octal, 0) == '0' &&
            (StrCharAt(octal, 1) == 'o' || StrCharAt(octal, 1) == 'O')) {
            start = 2;
        }
        while (StrIterPeek(&si, &c) && c != '\n') {
            if (kvconfig_is_comment_start(c) && StrLen(value) > 0 &&
                kvconfig_is_space(StrCharAt(value, StrLen(value) - 1))) {
                while (StrLen(value) > 0 && kvconfig_is_space(StrCharAt(value, StrLen(value) - 1))) {
                    char dropped = '\0';
            if (kvconfig_is_comment_start(c) && StrLen(value) > 0 &&
                kvconfig_is_space(StrCharAt(value, StrLen(value) - 1))) {
                while (StrLen(value) > 0 && kvconfig_is_space(StrCharAt(value, StrLen(value) - 1))) {
                    char dropped = '\0';
                    StrPopBack(value, &dropped);
    // Test StrCharAt function
    bool test_str_char_at(void) {
        WriteFmt("Testing StrCharAt\n");
        DefaultAllocator alloc = DefaultAllocatorInit();
        // Access characters at different indices
        // Now using the fixed StrCharAt macro
        char c0 = StrCharAt(&s, 0);
        char c1 = StrCharAt(&s, 1);
        char c2 = StrCharAt(&s, 2);
        // Now using the fixed StrCharAt macro
        char c0 = StrCharAt(&s, 0);
        char c1 = StrCharAt(&s, 1);
        char c2 = StrCharAt(&s, 2);
        char c3 = StrCharAt(&s, 3);
        char c0 = StrCharAt(&s, 0);
        char c1 = StrCharAt(&s, 1);
        char c2 = StrCharAt(&s, 2);
        char c3 = StrCharAt(&s, 3);
        char c4 = StrCharAt(&s, 4);
        char c1 = StrCharAt(&s, 1);
        char c2 = StrCharAt(&s, 2);
        char c3 = StrCharAt(&s, 3);
        char c4 = StrCharAt(&s, 4);
        char c2 = StrCharAt(&s, 2);
        char c3 = StrCharAt(&s, 3);
        char c4 = StrCharAt(&s, 4);
    
        // Check that the characters are correct
Last updated on