#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define ROWS 9
#define COLS 16
void RemoveAllOccurrencesOfWordFromString(char s[], char word[]) {
char arr[ROWS][COLS];
char *token = strtok(s, " ");
int i = 0;
while (token != NULL) {
strcpy(arr[i++], token);
token = strtok(NULL, " ");
}
s[0] = '\0';
for (int i = 0; i < ROWS; i++) {
if (strcmp (arr[i], word)) {
strcat(strcat(s, arr[i]), " ");
}
}
s[strlen(s) - 1] = '\0';
}
int main() {
char s[50] = "c++ c python c++ java c++ php c++";
char word[10] = "c++";
RemoveAllOccurrencesOfWordFromString(s, word);
puts(s);
}
/*
run:
c python java php
*/