Untitled

 avatar
unknown
plain_text
a year ago
511 B
5
Indexable
#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;
}
Editor is loading...
Leave a Comment