File:  [CSRG BSD Unix] / 43BSDReno / lib / libc / stdlib / bsearch.3
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:55 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43reno
BSD 4.3reno

.\" Copyright (c) 1990 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms are permitted
.\" provided that: (1) source distributions retain this entire copyright
.\" notice and comment, and (2) distributions including binaries display
.\" the following acknowledgement:  ``This product includes software
.\" developed by the University of California, Berkeley and its contributors''
.\" in the documentation or other materials provided with the distribution
.\" and in all advertising materials mentioning features or use of this
.\" software. Neither the name of the University nor the names of its
.\" contributors may be used to endorse or promote products derived
.\" from this software without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
.\"	@(#)bsearch.3	5.2 (Berkeley) 5/16/90
.\"
.TH BSEARCH 3 "May 16, 1990"
.UC 7
.SH NAME
bsearch - binary search of a sorted table
.SH SYNOPSIS
.nf
.ft B
#include <stdlib.h>
.sp
char *
bsearch(const void *key, const void *base,
size_t nmemb, size_t size,
int (*compar) (const void *, const void *));
.ft R
.fi
.SH DESCRIPTION
The
.I bsearch
function searches an array of
.I nmemb
objects, the inital member of which is 
pointed to by
.IR base ,
for a member that matches the object pointed to by
.IR key .
The size of each member of the array is specified by 
.I size .
.PP
The contents of the array should be in ascending sorted order according
to the comparison function referenced by
.IR compar .
.I Compar
is called with two arguments that point to the
.I key
object and to an array member, in that order, and must return an integer
less than, equal to, or greater than zero if the
.I key
object is considered, respectively, to be less than, equal to, or to
greater than the array member.
.PP
The
.I bsearch
function returns a pointer to a matching member of the array, or a null
pointer if no match is found.
If two members compare as equal, which member is matched is unspecified.
.SH "SEE ALSO"
hsearch(3), lsearch(3), qsort(3), tsearch(3)
.SH STANDARDS
.B Bsearch
conforms to ANSI X3.159-1989 (``ANSI C'').

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.