I think this is what you want:
char text[] = "I am here for all my life";
char text2[] = "They are here to win us all";
char *word = strtok(text, " ");
while (word != NULL) {
if (strstr(text2, word)) {
printf("Match: %s\n", word);
}
word = strtok(NULL, " ");
}
strtok() strstr() . , , , .
UPDATE:
, strstr() . strstr() . - :
#include <ctype.h>
int searchword(char *text, char *word) {
int i;
while (*text != '\0') {
while (isspace((unsigned char) *text))
text++;
for (i = 0; *text == word[i] && *text != '\0'; text++, i++);
if ((isspace((unsigned char) *text) || *text == '\0') && word[i] == '\0')
return 1;
while (!isspace((unsigned char) *text) && *text != '\0')
text++;
}
return 0;
}
, strstr() :
char text[] = "I am here for all my life";
char text2[] = "They are here to win us all";
char *word = strtok(text, " ");
while (word != NULL) {
if (searchword(text2, word)) {
printf("Match: %s\n", word);
}
word = strtok(NULL, " ");
}