#include <stdio.h>
int mycmp(const char* s1, const char* s2);
int cnt = 0;
char message [] = "the cat sat on the mat the the the the";
char checkword [] = "the";
int main (void)
{
char *word, *msg;
msg = message;
word = checkword;
if(mycmp(word, msg) == 0){
cnt++; // increment counter
}
//printf("The word is: %s\n", word);
//printf("the sentence is: %s\n", *message);
printf("the word occurs %i times\n", cnt);
return 0;
}
int mycmp (const char* s1, const char* s2)
{
while (*s1++ == *s2++);
return *s1 - *s2;
}