bsearch [C++ Reference]
Keywords: c,other,bsearch
Date: 2008-10-14T15:42:02-0700

[[bsearch]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- fr
- it
- jp
- pl
- ru
- tr

## bsearch

Syntax:

        #include <cstdlib>
        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.

Related Topics: qsort

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •