INtime SDK Help
lsearch

Performs a linear search for a specified value in an unsorted array, appending the value to the array if not found.

#include <search.h>

char *lsearch (
    const void *key, 
    const void *base,  
    unsigned int *num, 
    unsigned int width, 
    int (*compare) (
        const void *elem1, const void *elem2
    )
);

Parameters

key
Value being sought.
base
Pointer to base of the array to be searched.
num
Number of elements in the array.
width
Width of elements in bytes.
compare
Pointer to a user-supplied routine that compares two array elements, elem1 and elem2, and returns a value specifying their relationship.
elem1
Pointer to the key for the search.
elem2
Pointer to the array element to be compared with the key.

Remarks

lsearch calls the compare routine one or more times during the search, passing pointers to two array elements on each call. This routine must compare the elements, then return a non-0 value if the elements are different, or 0 if the elements are identical.

Return Values

A pointer to the array element that matches key.
Success.
A pointer to the newly added element in the array if a match is not found.
Failure.

Requirements

Versions Defined in Include Link to
INtime 3.0 intime/rt/include/search.h search.h clib.lib

See Also

bsearch, lfind