void *bsearch (const void * key , const void * base , size_t
nmemb , size_t size ,
int (*compar) (const void *, const
void *) );
The bsearch function searches an array of nmemb objects, the initial element of which is pointed to by base, for an element than matches the object pointed to by key. The size of each element in the array is specified by size.
The comparison function pointed to by compar is called with two arguments that point to the key object and an array element in that order. The function shall return an integer less than, equal to, or greater than zero if the key object is considered respectively to be less than, equal to or greater than the array element. The array shall consist of: all the objects that compare less than, all the elements that compare equal to, and all the elements that compare greater than the key object, in that order.
The bsearch function returns a pointer to a matching element of the array, or a null pointer if no match is found. If two elements compare as equal, which element is matched is unspecified.
The bsearch function cannot be used with expanded memory since it is not possible to pass the address of the compare function using the 1750's 16-bit address format.
A custom binary search function is likely to be smaller and faster than the library function. See Sedgewick, R., Algorithms in C, ISBN 0-201-51425-7, pp 198