title: Recursive binary search
body: <p>In my main file I have an array of character strings, char names[320][30], and after I sort that with a bubble sort. I want to be able to do a recursive binary search to determine if a word is present in the names array and what its index is.  The index is represented by a set of unsigned ints, unsigned int Set[10].  If the word is not present, the function should return -1.</p>
  
  <pre><code>#include "set.h"
  #include "sortAndSearch.h"
  #include &lt;stdio.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;string.h&gt;
  
  int binarySearch(Char A[][30], char *, int, int){
  //this gets passed the global array names
  //and the spot we're looking for is the char pointer
  //other 2 ints are low = 0, and high = 319
  //then it finds mid, a point between high and low
  //and then does the same thing on whichever half it needs
  //until it finds the index its looking for
  //this is recursive because of the low and high values provided
  
  int mid, low, high, result;
  
  //calculate midpoint to cut set in half
  mid = (high + low)/2;
  
  //comparison
  result = strcmp(A[mid], key);
  
  //if result &lt; 0, A[mid] &lt; key
  if(result &lt; 0)
          return binarySearch(A, key, mid+1, high);
  
  //if result &gt; 0, A[mid] &gt; key
  else if(result &gt; 0)
          return binarySearch(A, key, low, mid-1);
  
  //if result == 0, A[mid] == key
  else if(result == 0)
          return mid;
  
  //couldnt find it
  else
          return -1;
  
  //this should return int, either
  //the index where the string being searched for is stored in the array
  //or -1 to indicate that the string beinng sought is not in the array
  }
  </code></pre>
  
  <p>And in my main function, I call the function:</p>
  
  <pre><code>char *key;
  binarySearch(names, key, 0, 319);
  </code></pre>
  
  <p>When I try to compile, I get the following errors:</p>
  
  <ul>
  <li>search.c:7: parse error before "A"</li>
  <li>search.c: In function `binarySearch':</li>
  <li>search.c:7: number of arguments doesn't match prototype</li>
  <li>sortAndSearch.h:3: prototype declaration</li>
  <li>search.c:22: `A' undeclared (first use in this function)</li>
  <li>search.c:22: (Each undeclared identifier is reported only once</li>
  <li>search.c:22: for each function it appears in.)</li>
  <li>search.c:22: `key' undeclared (first use in this function)</li>
  </ul>
  
  <p>So my question is why am I getting these errors, as I do not see any typos, and what's up with the number of arguments not matching prototype?  I copied it right from the sortAndSearch.h file I was given. </p>