#include <iostream>
#include <string>
usingnamespace std;
char space = ' ';
int counting = 0, counting_2 = 0;
bool word_found = false;
int c, note;
void eliminate_word(char sentence[], char word[]);
int main (){
char phrase[1000], parola[50];
cout<<"Enter a phrase or sentence..."<<endl;
cin.getline(phrase, 999);
cout<<endl<<endl<<"Enter word to be eliminated..."<<endl;
cin>>parola;
eliminate_word(phrase, parola);
}
void eliminate_word(char sentence[], char word[]){
for (int i=0; i<50 ;i++ ){ if(word [i] != '\0' || word [i] != space)
{ counting ++;}
}
//searching the beginning of a word and checking lenght for elimination
for(int a = 0; a < 1000; a++) {
if (sentence [a]==word[0] && sentence[a-1] == space)
{ note = a; c = (note + counting-1) /* to help check if at least lenght is equal*/ ;}
for (int k = a; k < c; c++) {if (sentence[k] != 0 || sentence [k]!= space || sentence [k] != '\0') counting_2 ++; }
if (counting_2 == counting){ for(int i = 0; i<counting; i++){ if (word[i]== sentence [note+i]) word_found = true;}
if (word_found == true)
for (int i = 0; i< counting; i++){sentence[note+i] = space;}
}
}
cout<<"Sentence with word eliminated is "<<endl<<sentence<<endl;
}
Use std::string to hold the sentence and the word to be eliminated, std::string::find() to locate the white-space-delimited word, std::string::erase() to erase the word and the white space following it.