- 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
bsearchsearches a sorted array for a member that matches the one pointed to bykey.baseis the address of the array,nis the number of elements,sizethe size of an element andcmpthe function used to compare the members against the key. The function returns a pointer to the member found, orNULLif 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.