#include // Some standard functions in here #include // StrCMP /* SUBSTR_COUNT * @ Method input: [WORD TO SEARCH FOR] [SENTECE] * @ Method return: INT, how much word apperas in sentece */ int count_words(char *, char *); // ProtoType int count_words(char *word, char *sentece) { int result = 0; while(*sentece != '\0') { int i = 0; char buf[256]; while(*(sentece++) != ' ') buf[i] = *sentece; if(strncmp(buf, word, i) == 0) result++; } return result; } int main() { char first[] = "Hello my name is noob hello hello hello"; char search[] = "hello"; int times = count_words(search, first); printf("Word %s is %d times in %s! ",search, times, first); }