Manpage of LSEARCH

LSEARCH

Section: Linux Programmer's Manual (3)
Updated: 2015-08-08
Index
 

NAME

lfind, lsearch - linear search of an array  

SYNOPSIS

#include <search.h>void *lfind(const void *key, const void *base, size_t *nmemb,         size_t size, int(*compar)(const void *, const void *));void *lsearch(const void *key, void *base, size_t *nmemb,         size_t size, int(*compar)(const void *, const void *));
 

DESCRIPTION

lfind() and lsearch() perform a linear search for keyin the array basewhich has *nmembelements of sizebytes each. The comparison function referenced by comparis expected to have two arguments which point to the keyobject and to an array member, in that order, and which returns zero if the keyobject matches the array member, and nonzero otherwise.

If lsearch() does not find a matching element, then the keyobject is inserted at the end of the table, and *nmembis incremented. In particular, one should know that a matching element exists, or that more room is available.  

RETURN VALUE

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

ATTRIBUTES

For an explanation of the terms used in this section, see attributes(7).
InterfaceAttributeValue
lfind(), lsearch() Thread safetyMT-Safe

 

CONFORMING TO

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

BUGS

The naming is unfortunate.  

SEE ALSO

bsearch(3), hsearch(3), tsearch(3)


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
ATTRIBUTES
CONFORMING TO
BUGS
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 16:30:20 GMT, October 09, 2016 Click Here!