Skip to content

VecLast

VecLast

Description

Value of last element in vector.

Parameters

Name Direction Description
v in Vector to get last element of.

Usage example (Cross-references)

Usage examples (Cross-references)
            case VEC_CHAR_PTR_LAST : {
                if (VecLen(vec) > 0) {
                    char *last = VecLast(vec);
                    (void)last; // Use the result to avoid warnings
                }
            case VEC_STR_LAST : {
                if (VecLen(vec) > 0) {
                    Str last = VecLast(vec);
                    (void)last; // Use the result to avoid warnings
                }
            case VEC_INT_LAST : {
                if (VecLen(vec) > 0) {
                    volatile i32 last = VecLast(vec);
                    (void)last;
                }
    // Test VecFirst and VecLast functions
    bool test_vec_first_last(void) {
        WriteFmt("Testing VecFirst and VecLast\n");
    
        // Create a vector of integers
        // Check first and last elements
        bool result = (VecFirst(&vec) == 10);
        result      = result && (VecLast(&vec) == 30);
    
        // Modify first and last elements
        // Modify first and last elements
        VecFirst(&vec) = 15;
        VecLast(&vec)  = 35;
    
        // Verify changes
    /// Access last character in string
    ///
    #define StrLast(str) VecLast(str)
    
    ///
Last updated on