Delete word from string

Description:

Following C++ program ask to the user to enter a sentence then ask to enter a word to be delete from the sentence, then display the new sentence after deleting the given word: Test Case 1 Input (stdin) welcome srm university srm Expected Output The new String after deleting the word:welcome university Test Case 2 Input (stdin) this is string is Expected Output The new String after deleting the word:this string

Program :

#include<iostream>

#include<string.h>

using namespace std;

int main()

{

 string s;

  int i, j = 0, k = 0;

    char str1[10][20], word[20];

    getline(cin,s);

  cout<<"The new String after deleting the word:";

    for (i=0; s[i]!='\0'; i++)

    {

if (s[i]==' ')

{

    str1[k][j] = '\0';

    k++;

    j=0;

}

else

{

    str1[k][j]=s[i];

    j++;

}}

    str1[k][j] = '\0';

    cin>>word;

    for (i=0; i<k+1; i++)

    {

if (strcmp(str1[i], word) == 0)

{

    for (j=i; j<k+1; j++)

{

strcpy(str1[j], str1[j + 1]);

k--;

}}}

    for (i=0; i<k+1; i++)

cout<<str1[i]<<" ";

  return 0;

}