title: How to pass a vector to a function?
body: <p>I'm trying to send a vector as an argument to a function and i can't figure out how to make it work. Tried a bunch of different ways but they all give different error messages.
  I only include part of the code, since it's only this part that doesn't work.
  (the vector "random" is filled with random, but sorted, values between 0 and 200)</p>
  
  <p>Updated the code:</p>
  
  <pre><code>#include &lt;iostream&gt;     
  #include &lt;ctime&gt;        
  #include &lt;algorithm&gt;    
  #include &lt;vector&gt;       
  
  using namespace std;
  
  int binarySearch(int first, int last, int search4, vector&lt;int&gt;&amp; random);
  
  int main()
  {
      vector&lt;int&gt; random(100);
  
      int search4, found;
      int first = 0;
      int last = 99;
  
      found = binarySearch(first, last, search4, random);
  
      system("pause");    
      return(0);      
  }
  
  int binarySearch(int first, int last, int search4, vector&lt;int&gt;&amp; random)
  {
      do
      {
          int mid = (first + last) / 2;  
          if (search4 &gt; random[mid]) 
              first = mid + 1;  
          else if (search4 &lt; random[mid]) 
              last = mid - 1; 
          else
              return mid;     
      } while (first &lt;= last); 
  
      return -(first + 1);
  }
  </code></pre>