Do a binary search in a sorted array.
void* __fastcall__ bsearch (const void* key, const void* base, size_t n, size_t size, int (*cmp) (const void*, const void*));
bsearchsearches a sorted array for a member that matches the one pointed to by
baseis the address of the array,
nis the number of elements,
sizethe size of an element and
cmpthe function used to compare the members against the key. The function returns a pointer to the member found, or
NULLif there was no match.
- The contents of the array must be sorted in ascending order according to the compare function given.
- If there are multiple members that match the key, the function will return one of the members.
- The function is only available as fastcall function, so it may only be used in presence of a prototype.
- See also