169. Calling the bsearch() foreign function
The In a nutshell, this method gets pointers to a key, a sorted array ( The callback function gets a pointer to The bsearch() foreign function is part of the C standard library and has the following signature (void *bsearch(
const void *key,
const void *base,
size_t num,
size_t width,
int ( __cdecl *compare ) (
const void *key, const void *datum)
);
base), and a comparator. Its goal is to use the given comparator to perform a binary search of the given key in the given array. More precisely, bsearch() gets a pointer to the key, a pointer to the array, the number of elements in the array (num), the size of an element in bytes (width), and the comparator as a callback function. key and a pointer to the current element of the array to be compared with key. It returns the result of comparing these two elements.bsearch() function returns...