liveBook · Manning

Bsearch

bsearch is a C standard-library function that performs a binary search on a sorted array using a caller-provided comparison function.

How 2 Manning books explain it

Modern C, Third Edition

bsearch is the C standard-library function that performs a binary search on a sorted array using a comparison function.

How it is used
Provides generic binary searching for sorted arrays through a caller-supplied ordering function.
How deep it goes
Explains the interface, erased array types, element sizing, and comparator contract without descending into search-loop internals.
Examples
Uses unsigned comparison code and contrasts safe relational comparison with overflow-prone integer subtraction.
What you can do after
Apply it via the C standard library with correctly sized elements and a consistent comparator.

Read how Modern C, Third Edition explains bsearch →

Modern C

bsearch is a C standard library function that searches a sorted array using a caller-provided comparison function.

How it is used
Uses a caller-provided comparator to search sorted arrays without depending on their element type.
How deep it goes
Defines the interface and comparator contract, but does not explain the search algorithm’s internal steps.
Examples
Uses unsigned comparison code and contrasts it with an overflowing integer subtraction comparator.
What you can do after
Apply via the C standard library by supplying correctly sized elements and a consistent comparison function.

Read how Modern C explains bsearch →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.