I am trying my hands on binary search. I get those pointer to integer errors :( Can sonmeone more experience give me a hand ?
bool search(int value, int values[], int n)
{
int first=0;
int last=n-1;
int middle=(first+last)/2;
while (values[first]!=values[last])
middle=(first+last)/2;
if (value==values[middle])
{
return true;
}
else if (value<values[middle])
{
last=(n/2)-1;
search(value,values[first],(n/2)-1);
}
else if (value>values[middle])
{
first=middle+1;
search(value,values[middle+1],(n/2)-1);
}
if (values[first]==value)
{
return true;
}
else
{
return false;
}
the errors i get is one of those :
hello.c:35:22: error: incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'; take the address with & [-Werror,-Wint-conversion] search(value,values[first],(n/2)-1);