bsearch
- Updated2023-02-21
- 1 minute(s) read
bsearch
void *bsearch (const void *keyToFind, const void *baseArrayElement, size_t numberOfElements, size_t elementSize, int (*comparisonFunction)(const void *, const void *));
Purpose
Searches an array of objects for an element that matches a specified key. The array must already be sorted in ascending order.
Parameters
Input | ||||||||||
Name | Type | Description | ||||||||
keyToFind | const void * | The key element to find in the array. | ||||||||
baseArrayElement | const void * | The array to be searched. number_ofElements specifies the number of elements in the array. elementSize describes the size of each element in the array. | ||||||||
numberOfElements | size_t | Specifies the number of elements in the array. | ||||||||
elementSize | size_t | The size in bytes of each element in the array. | ||||||||
comparisonFunction | int (*)(const void *, const void *) |
The name of a function used to compare an element of the array with
the key.
|
Return Value
Name | Type | Description |
matchingElement | void * | A pointer to the matching element of the array or a null pointer if no match is found. If two elements compare as equal, the element that is matched is unspecified. |
Additional Information
Library: ANSI C Library
Include file: ansi_c.h
LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later