Search for the position of a name in the array using a recursive binary search

I have written a program that takes an array of twenty strings, sorts then in ascending ASCII order using selection sort and then searches for the position of the name in the array using a recursive binary search.  Upon compiling I receive the following error message: warning: passing arg 3 of `search' from incompatible pointer type.  Can you please help me determine the correct pointer type for the program to compile?  The program is to read the strings from a file but I have initalized the array within main for the time being.

The program is as follows:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define NUMWORDS 20
#define LENWORDS 25

//Prototypes
void displayName (void);
int search (int start, int end, char *words [], const char s[]);

//Main controls the

int main (int argc, char *argv[])
{
   FILE *infptr;
   char words [NUMWORDS][LENWORDS] =
{"love","mary","had","a","little","lamb","its","fleece","was","white","as","snow","ittzy","bittzy","spider","came","down","the","water","spout"};
   int i,j,k;
   int currMin=0;
   char temp[NUMWORDS];
   int result;
   char searchWord [LENWORDS];
   if (argc <= 1)
   {
     printf("\nNot enough command line arguments.\n");
   }
   infptr = fopen (argv [1], "r");
   if ((infptr)==NULL)
   {
      printf("\nERROR: Unable to open data for reading.\n\n");
   }
   if ((argc>=2) && ((infptr)!=NULL))
   {
      displayName ();
      for (j=0; j < 19; j++)
      {
         currMin=j;
         for (k=j+1; k < 20; k++)
            if (strcmp(words[currMin], words[k])>0)
            currMin=k;
         strcpy(temp, words[currMin]);
         strcpy(words[currMin], words [j]);
         strcpy(words[j],temp);
         }
      for (i=0; i < NUMWORDS; i++)
         printf ("\n%d: %s", i, words[i]);
         printf ("\n\n");

         printf("Please enter a word to search (or quit to stop): ");
         scanf ("%s", searchWord);
         result = search (0, NUMWORDS - 1, words, searchWord);
         printf("The word \"%s\"", searchWord);
         if (result == -1)
            printf ("was not found.\n");
         else
         printf ("was found at position %d.\n", result);
   }
   //Format and finish.
   printf ("\n");
   return 0;
}

//The name of the programmer is displayed.
void displayName (void)
{
   printf("\nName: Chandra Parr\n\n");
}

int search (int start, int end, char *words [], const char s[])
{
   int middle, cmpRes;
   
   if (start > end)
      return (-1);
   else if (start == end)
      if (strcmp(words[start], s) == 0)
         return start;
      else
         return (-1);
   else
   {
      middle = (start + end) / 2;
      cmpRes = strcmp(words[middle],s);
      if (cmpRes == 0)
         return middle;
      else if (cmpRes > 0)
         return search(start, middle - 1, words, s);
      else
         return search (middle + 1, end, words, s);
   }
}
csunnypl2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HendrikTYRCommented:
Hi,

You'll get better responses on this if you post it in the "C Programming" section.

Regards
Hendrik
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.