N64® Functions Menu

al - Audio Library Functions
gDP - DP GBI Macros
gdSP - General GBI Macros
gSP - SP GBI Macros
gt - Turbo Microcode RDP
gu - Graphics Utilities
Math - Math Functions
nuSys - NuSystem
os - N64 Operating System
sp - Sprite Library Functions
uh - Host to Target IO
64DD - N64 Disk Drive

Nintendo® Confidential

## bsearch

Syntax

    #include <string.h>
    void *bsearch(const void *key,
       const void *base,
       size_t num,
       size_t width,
       int (*compare)(void *, void*));

Arguments

- key is the key to be found
- base is the pointer to the array to be found
- num is the number of elements in the array to be found
- width is the size of one element in the array (byte unit) to be found
- compare is the pointer to the comparison function created by the user

Return Value
A pointer to the elements that were found, or NULL if nothing is found
Explanation
Using a binary search, it finds an element that matches the key argument in an array sorted in ascending order. If the array is not in ascending order, the key can't be found.
The compare argument points to the comparison function that you create in the following form:
int compare ((type *) elem1, (type *) elem2);
The type specifier is optional. If the value returned is less than zero, elem1 is smaller than elem2. If the value returned is zero, elem1 is equal to elem2. And if the value returned is more than zero, elem1 is larger than elem2.
Note
This standard function comes with NuSystem.

Nintendo® Confidential Warning: all information in this document is confidential and covered by a non-disclosure agreement. You are responsible for keeping this information confidential and protected. Nintendo will vigorously enforce this responsibility.
Copyright © 1998
Nintendo of America Inc. All rights reserved
Nintendo and N64 are registered trademarks of Nintendo
Last updated March 1998