#include <stdio.h>
#include <string.h>
int main() {
char s[50] = "c++ c python c++ java c++ php c++";
char *p = s;
char word[10] = "c++";
int word_index = p - s;
while( (p = strstr(p, word)) ) {
printf("%s\n", p);
printf("index = %i\n\n", p - s);
p++;
}
}
/*
run:
c++ c python c++ java c++ php c++
index = 0
c++ java c++ php c++
index = 13
c++ php c++
index = 22
c++
index = 30
*/