Given the array of strings beatles whose contents include j
Given the array of strings beatles[ ] whose contents include “john”, “paul”, “george” and “ringo”, build a search function called search() that will search the list for names to see whether they were one of the Beatles or not. Start with
char * beatles[4] = {“john”, “paul”, “george”, “ringo”};
Now write a search function to search this array and see whether “george” and “ringo” are in that list. Then check to see whether “mick” and “bruce” are on that list.
Solution
char * beatles[4] = {“john”, “paul”, “george”, “ringo”};
 int search(char *str)
 {
    int i,c;
    c=0;
    for(i=0;i<4;i++)
    {
        c=strcmp(*(beatles+i),*str);
        if(c==0)
        {
            printf(\"found\ \");
            return;
        }
    }
    printf(\"not found\");
 }
![Given the array of strings beatles[ ] whose contents include “john”, “paul”, “george” and “ringo”, build a search function called search() that will search the  Given the array of strings beatles[ ] whose contents include “john”, “paul”, “george” and “ringo”, build a search function called search() that will search the](/WebImages/35/given-the-array-of-strings-beatles-whose-contents-include-j-1102191-1761582618-0.webp)
