Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4 |
both |
#define _XOPEN_SOURCE
#include <search.h>
void *lfind(const void *key, const void *base, size_t *nelp,
size_t width, int (*compar)(const void *, const void *));
The lfind() function is the same as a lsearch() except that if the entry is not found, it is not added to the table. Instead, a NULL pointer is returned.
Special behavior for C++: Because C and C++ linkage conventions are incompatible, lfind() cannot receive a C++ function pointer as the comparator argument. If you attempt to pass a C++ function pointer to lfind(), the compiler will flag it as an error. You can pass a C or C++ function to lfind() by declaring it as extern "C".
If the searched-for entry is found, lfind() returns a pointer to it.
If not found, lfind() returns a NULL pointer.
No errors are defined.