VecPopBack

Table of Contents

VecPopBack

Description

Pop item from vector back.

Parameters

NameDirectionDescription
vin,outVector to pop item from.
ptroutPopped item 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 item from last position.

Success

return

Failure

Does not return

Usage example (Cross-references)

    /// FAILURE : Returns NULL otherwise.
    ///
    #define StrPopBack(str, chr) VecPopBack((str), (chr))
    
    ///
    /// FAILURE : Does not return
    ///
    #define VecDeleteLast(v) VecPopBack((v), (VEC_DATATYPE(v) *)NULL)
    
    ///
    // Test VecPopBack function
    bool test_vec_pop_back(void) {
    printf("Testing VecPopBack\n");
    
    // Create a vector of integers
    // Pop from the back
    int popped;
    VecPopBack(&vec, &popped);
    
    // Check popped value
    
    // Pop again
    VecPopBack(&vec, &popped);
    
    // Check popped value

Share :