Skip to content

StrPopBack

Description

Remove the last character from the string and optionally store it. Pass NULL for chr to discard. See VecPopBack for the full SUCCESS/FAILURE contract.

Usage example (Cross-references)

Usage examples (Cross-references)
                while (StrLen(value) > 0 && kvconfig_is_space(StrCharAt(value, StrLen(value) - 1))) {
                    char dropped = '\0';
                    StrPopBack(value, &dropped);
                }
                return si;
    // Test StrPopBack function
    bool test_str_pop_back(void) {
        WriteFmt("Testing StrPopBack\n");
        DefaultAllocator alloc = DefaultAllocatorInit();
        // Pop a character from the back
        char c;
        StrPopBack(&s, &c);
    
        // Check that the character was popped correctly
        // Pop another character without storing it - avoid passing NULL directly
        char ignored;
        StrPopBack(&s, &ignored);
    
        // Check that the character was removed
Last updated on