#include #include #include int compare_strings(const void *e1, const void *e2); int main() { char strings[][20] = { "apples", "grapes", "strawberries", "bananas" }; char item[20] = "strawberries"; //sort the strings qsort(strings, 4, 20, compare_strings); //search for strawberries char *pos = (char *) bsearch(item, strings, 4, 20, compare_strings); if (pos) printf("The string \"%s\" was found.\n", pos); return 0; } int compare_strings(const void *e1, const void *e2) { return strcmp((char *) e1, (char *) e2); }