#include <stdio.h>
#include <string.h>
int countOccurrences(const char *str, const char *sub) {
if (sub[0] == '\0') return 0;
int count = 0;
const char *tmp = str;
while ((tmp = strstr(tmp, sub)) != NULL) {
count++;
tmp += strlen(sub);
}
return count;
}
int main() {
const char *s = "java php c c++ python php phphp";
printf("%d\n", countOccurrences(s, "php"));
return 0;
}
/*
run:
3
*/