StrPopFront

Table of Contents

StrPopFront

Description

Pop char from string front.

Parameters

NameDirectionDescription
strin,outStr to pop char from.
valoutPopped char will be stored here. Make sure this has sufficient memory to store memcopied data. If no pointer is provided, then it’s equivalent to deleting char from last position.

Success

Returns str on success

Failure

Returns NULL otherwise.

Usage example (Cross-references)

    // Test StrPopFront function
    bool test_str_pop_front(void) {
    printf("Testing StrPopFront\n");
    
    Str s = StrInitFromZstr("Hello");
    // Pop a character from the front
    char c;
    StrPopFront(&s, &c);
    
    // Check that the character was popped correctly
    // Pop another character without storing it - avoid passing NULL directly
    char ignored;
    StrPopFront(&s, &ignored);
    
    // Check that the character was removed

Share :