I have written my binary search code, but every time i try to compile I get the following error
jharvard@appliance (~/Dropbox/pset3/find): make helpers
clang -ggdb3 -O0 -std=c99 -Wall -Werror helpers.c -lcs50 -lm -o helpers
helpers.c:49:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]
}
^
1 error generated.
make: *** [helpers] Error 1
Here is my code:
bool search (int value, int values[], int n)
{
if (n > 0)
{
int min = 0, max = n-1;
while (n > 0)
{
int mid = ((min + max)/2);
if (value == values[mid])
{
return true;
}
else if (value < values[mid])
{
max = mid - 1;
continue;
}
else
{
min = mid + 1;
continue;
}
return false;
}
}
else
return false;
}
Can you explain what's wrong?