void * bsearch ( const void * key,
const void * base,
size_t num,
size_t size,
int ( * comparator ) ( const void *, const void * ) );
If I pass in a const void * base
, shouldn't bsearch
also return a const void *
result?
When you search for something, it's a valid request that you be able to modify it after you found it. It would be too restrictive if the search function didn't allow you to do that. Of course such a modification could break a subsequent search, but that's a different matter.
The parameters are const as a promise that bsearch itself will not modify them, which is reasonable.