bsearch
Syntax:
#include <stdlib.h> void *bsearch( const void *key, const void *buf, size_t num, size_t size, int (*compare)(const void *, const void *) ); The bsearch() function searches buf[0] to buf[num-1] for an item that matches key, using a binary search. The function compare should return negative if its first argument is less than its second, zero if equal, and positive if greater. The items in the array buf should be in ascending order. The return value of bsearch() is a pointer to the matching item, or NULL if none is found. |