2
$Id: bsearch-3.c,v 1.1 2007/02/06 12:36:58 dmix Exp $
9
size_t size; /* to pass size of members */
11
int cmp (const void *p1, const void *p2)
13
return memcmp(p1, p2, size);
22
/* Filling of arr: 0,1,2... */
23
for (i= 0; (size_t)i < sizeof(arr); i++)
26
for (size= 1; size <= sizeof(arr); size++) {
27
for (nmemb= 1; nmemb <= sizeof(arr) / size; nmemb++) {
28
/* scanning all keys */
29
for (i= 0; (size_t)i <= sizeof(arr) - size; i++) {
30
if ((i % size) == 0 && (i / size) < nmemb) {
31
if (bsearch (arr + i, arr, nmemb, size, cmp) != arr + i) {
33
printf ("size= %d nmemb= %d i= %d\n",
39
if (bsearch (arr + i, arr, nmemb, size, cmp))