Synopsis
#include <stdlib.h>
void *bsearch(const void *key, const void *base, size_t num, size_t size, int (*compare)(const void *, const void *));
Description

bsearch searches the array *base for the specified *key and returns a pointer to the first entry that matches or null if no match. The array should have num elements of size bytes and be sorted by the same algorithm as the compare function. The compare function should return a negative value if the first parameter is less than second parameter, zero if the parameters are equal and a positive value if the first parameter is greater than the second parameter.

Portability

bsearch conforms to ISO/IEC 9899:1990 (C90) and ISO/IEC 9899:1999 (C99).