**bsearch function:** It is used to do a binary search on an array and to return a pointer to first matching member. Here array is sorted in ascending order.

Syntax:

void *bsearch(const void *key, const void *buffer, size_t num, size_t size, int (*compare)(const void *, const void *));

compare function is used which has the syntax:

int function-name(const void *argumenta, const void *argumentb);

If argument a is less than argument b, a value less than zero is returned. If argument a is greater than argument b, a value greater than zero is returned. If argument a is equal to argument b, zero is returned.

**qsort function:** It is used to do a quick sort on an array. Here array is sorted in ascending order.

Syntax:

void qsort(void *buffer, size_t num, size_t size, int (*compare) (const void *, const void *));

compare function is used which has the syntax:

int function-name(const void *argumenta, const void *argumentb);

If argument a is less than argument b, a value less than zero is returned. If argument a is greater than argument b, a value greater than zero is returned. If argument a is equal to argument b, zero is returned.

## Leave a Reply