It depends on if you want to pass the vector as a reference or as a pointer (I am disregarding the option of passing it by value as clearly undesirable).
As a reference:
int binarySearch(int first, int last, int search4, vector
vector
// …
found = binarySearch(first, last, search4, random);
As a pointer:
int binarySearch(int first, int last, int search4, vector
vector
// …
found = binarySearch(first, last, search4, &random);
Inside binarySearch, you will need to use . or -> to access the members of random correspondingly.
Issues with your current code
binarySearch expects a vector
You do not dereference the pointer inside binarySearch before using it (for example, random[mid] should be (*random)[mid]
You are missing using namespace std; after the
The values you assign to first and last are wrong (should be 0 and 99 instead of random[0] and random[99]
You’ll have to pass the pointer to the vector, not the vector itself. Note the additional ‘&’ here:
found = binarySearch(first, last, search4, &random);