C - Pointers to Functions Example..

Yes, just another one!

#include <stdio.h>
#include <string.h>
 
void find(char *stringArray[], int (*function_name) (char *s));
int is_harika(char *s);
int is_not_muhtesem(char *s);
 
int NUM_ADS = 6;
 
int main(int argc, char const *argv[]) {
    char *ads[] = {
    "one: harika, frikik",
    "two: muhtesem, harika",
    "three: oyle boyle, harika",
    "four: harika",
    "five: muhtesem",
    "six: harika, muhtesem"
    };
    printf("%s\n", "Printing is harika:");
    find(ads, is_harika);
    printf("%s\n", "Printing is_not_muhtesem:");
    find(ads, is_not_muhtesem);
    return 0;
}
 
void find(char *stringArray[], int (*function_name) (char *s) ) {
    for (int i = 0; i < NUM_ADS; i++) {
        if (function_name(stringArray[i])) {
            printf("%s\n", stringArray[i]);
        }    
    }
}
 
int is_harika(char *s) {
    if (strstr(s,"harika")) {
        return 1;
    }
    return 0;
}
 
int is_not_muhtesem(char *s){
    if (!strstr(s,"muhtesem")) {
        return 1;
    }
    return 0;
}