When attempting to implement binary search, I have run into problems when compiling. If you see any problems in sort, please point them out as well. Any help would be appreciated. Here are the errors:
clang -ggdb3 -O0 -std=c99 -Wall -Werror -o find find.c helpers.c -lcs50 -lm
helpers.c:20:6: error: conflicting types for 'bsearch'
bool bsearch(int key, int array[], int min, int max)
^
/usr/include/stdlib.h:755:14: note: previous declaration is here
extern void *bsearch (const void *__key, const void *__base,
^
helpers.c:34:52: error: too few arguments to function call, expected 5, have 4
return bsearch(key, array, mid + 1, max);
~~~~~~~ ^
/usr/include/stdlib.h:755:1: note: 'bsearch' declared here
extern void *bsearch (const void *__key, const void *__base,
^
helpers.c:38:52: error: too few arguments to function call, expected 5, have 4
return bsearch(key, array, min, mid - 1);
~~~~~~~ ^
/usr/include/stdlib.h:755:1: note: 'bsearch' declared here
extern void *bsearch (const void *__key, const void *__base,
^
helpers.c:52:39: error: too few arguments to function call, expected 5, have 4
bsearch(value, values, values[0], n);
~~~~~~~ ^
/usr/include/stdlib.h:755:1: note: 'bsearch' declared here
extern void *bsearch (const void *__key, const void *__base,
^
4 errors generated.
make: *** [find] Error 1
Here is my code:
/**
* helpers.c
*
* Computer Science 50
* Problem Set 3
*
*/
#include <cs50.h>
#include <math.h>
#include "helpers.h"
/**
* Returns true if value is in array of n values, else false.
*/
//Recursive Search
bool bsearch(int key, int array[], int min, int max)
{
int mid1 = 0;
[mod: snipped code as not necessary to answer question.]