Customizing compare in bsearch()
Posted
by Richard Smith
on Stack Overflow
See other posts from Stack Overflow
or by Richard Smith
Published on 2010-03-24T05:24:29Z
Indexed on
2010/03/24
5:33 UTC
Read the original article
Hit count: 148
c++
I have an array of addresses that point to integers ( these integers are sorted in ascending order). They have duplicate values. Ex: 1, 2, 2, 3, 3, 3, 3, 4, 4......
I am trying to get hold of all the values that are greater than a certain value(key). Currently trying to implement it using binary search algo -
void *bsearch(
const void *key,
const void *base,
size_t num,
size_t width,
int ( __cdecl *compare ) ( const void *, const void *)
);
I am not able to achieve this completely, but for some of them.
Would there be any other way to get hold of all the values of the array, with out changing the algorithm I am using?
© Stack Overflow or respective owner