- Function
Do a binary search in a sorted array.
- Header
- Declaration
void* __fastcall__ bsearch (const void* key, const void* base, size_t n, size_t size, int (*cmp) (const void*, const void*));
- Description
bsearch
searches a sorted array for a member that matches the one pointed to bykey
.base
is the address of the array,n
is the number of elements,size
the size of an element andcmp
the function used to compare the members against the key. The function returns a pointer to the member found, orNULL
if there was no match.- Limits
- 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.
- Availability
ISO 9899
- See also
- Example
None.