Afternoon guys. I have written the function listed below. It is a binary search function that is supposed to search through a 2d array (dict) for a word (word).
My issue is that with both strcmp commands, I receive the error "passing argument 1 of 'strcmp' makes pointer from integer without cast." I googled it, but I didn't come up with any concrete answers. Thanks.
Code:
int binsearch (char dict[][19], int maxWords, char word) {
int low = 0;
int high = maxWords-1;
int FOUND = 0;
while (low <= high) {
int mid = (low + high)/ 2;
if ((strcmp(word,dict[mid])) < FOUND)
high = mid-1;
else if ((strcmp(word,dict[mid])) > FOUND)
low = mid+1;
else
return 1;
}
return 0;
}