title: Recursive binary search program in C
body: <p>I am trying to create a recursive binary search function in C. I think I have it, but when I try to compile, I get the error "expected primary-expression before ']' token" for both recursive calls. Does anyone know why this is occurring?</p>
  
  <p>My function:</p>
  
  <pre><code>int binSearch(int val, int a[], int size)
  {
           int mid;
           mid=(size)/2;
           if(val==a[mid]) return a[mid];
           else if(val&lt;a[mid]) {
                return binSearch(val, a[], (size-mid));
           }
           else if(val&gt;a[mid]) {
                return binSearch(val, a[], size);
           }
           else return(-1);
   }
  </code></pre>
  
  <p>Where a[] is the sorted array, size is the size of the array, and val is the value being searched for.</p>