1LSEARCH(3)                 Linux Programmer's Manual                LSEARCH(3)
2
3
4

NAME

6       lfind, lsearch - linear search of an array
7

SYNOPSIS

9       #include <search.h>
10
11       void *lfind(const void *key, const void *base, size_t *nmemb,
12                size_t size, int(*compar)(const void *, const void *));
13
14       void *lsearch(const void *key, void *base, size_t *nmemb,
15                size_t size, int(*compar)(const void *, const void *));
16

DESCRIPTION

18       lfind() and lsearch() perform a linear search for key in the array base
19       which has *nmemb elements of size bytes each.  The comparison  function
20       referenced  by  compar is expected to have two arguments which point to
21       the key object and to an array member, in that order, and which returns
22       zero if the key object matches the array member, and nonzero otherwise.
23
24       If  lsearch()  does not find a matching element, then the key object is
25       inserted at the end of the table, and *nmemb is incremented.   In  par‐
26       ticular,  one  should know that a matching element exists, or that more
27       room is available.
28

RETURN VALUE

30       lfind() returns a pointer to a matching member of the array, or NULL if
31       no match is found.  lsearch() returns a pointer to a matching member of
32       the array, or to the newly added member if no match is found.
33

CONFORMING TO

35       SVr4, 4.3BSD, POSIX.1-2001.  Present in libc since libc-4.6.27.
36

BUGS

38       The naming is unfortunate.
39

SEE ALSO

41       bsearch(3), hsearch(3), tsearch(3)
42

COLOPHON

44       This page is part of release 3.53 of the Linux  man-pages  project.   A
45       description  of  the project, and information about reporting bugs, can
46       be found at http://www.kernel.org/doc/man-pages/.
47
48
49
50GNU                               1999-09-27                        LSEARCH(3)
Impressum