Untitled

mail@pastecode.io avatar
unknown
plain_text
19 days ago
511 B
1
Indexable
Never
#include <stdio.h>
#include <string.h>

#define SIZE 1000

int main(void) {
    char *term;
    char *current_string;
    int count = 0;
    printf("Enter the search term: ");
    fgets(term, SIZE, stdin);
    printf("Enter the list of strings: \n");
    

    while (fgets(current_string, SIZE, stdin) != NULL) {
        if ((strcmp(term, current_string)) == 0) {
            count++;   
        }
    } 
    printf("There was %d occurrence(s) of the search term in the input.\n", count);
    
    return 0;
}
Leave a Comment