2. Show the error messages that you get. In general be explicit about what you want or need or what you are facing. For example, I don't bother in even looking at code that is not within code tags, and much less if I don't have a description of what I'm looking for. Others may work similarly.
gives me following errors:
|52|error: invalid conversion from 'int' to 'int*'|
|52|error: initializing argument 1 of 'bool BinarySearch(int*, int)'|
|53|warning: suggest parentheses around assignment used as truth value|
||=== Build finished: 2 errors, 1 warnings ===|
You're trying to pass array[256] into the function BinarySearch. That's wrong. Here, look:
array[0] is the first element of the array. It's an int. Right? So, array[256] is another int, which is actually off the end of your array. Not only are you trying to pass an int to a function that expects an int*, you're passing an int that doesn't even exist.
Change this bool BinarySearch(int a[256], int t)//* binary search algorithm
to bool BinarySearch(int a[], int t)//* binary search algorithm
And pass to the function like this: search_result = BinarySearch(array, target);//* error: invalid conversion from ' int ' to ' int* '
Not like this: search_result = BinarySearch(array[256], target);//* error: invalid conversion from ' int ' to ' int* '
And I think your warning is that there is no return statement if the while loop isn't true: