A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.wikibooks.org/wiki/C++_Programming/Code/Standard_C_Library/Functions/bsearch below:

C++ Programming/Code/Standard C Library/Functions/bsearch - Wikibooks, open books for an open world

From Wikibooks, open books for an open world

Syntax
#include <cstdlib>
void* bsearch( const void *key, const void *base, size_t num, size_t size, int (*compare)(const void *, const void *));

The function bsearch() performs a search within a sorted array, returning a pointer to the element in question or NULL.

*key refers to an object that matches an item searched within *base. This array contains num elements, each of size size.

The compare function accepts two pointers to the object within the array - which need to first be cast to the object type being examined. The function returns -1 if the first parameter should be before the second, 1 if the first parameter is after, or 0 if the object matches.

Related topics
qsort

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4