title: Program to remove all occurrences of a word in given string
body: <p>I have written the code but the output is not coming correct: if I input <code>How you doing</code> as an original string and then want to remove <code>you</code>, the output should be <code>How doing</code>, but instead the output is coming as <code>How you doing</code> (same as the input string).</p>
  
  <p>Here is my code:</p>
  
  <pre><code>void removeWord(char *,char *);
  
  int main() {
      char str[100];
      printf("Enter any string: ");
      gets(str);
  
      char re[20];
      printf("\nEnter word to remove: ");
      gets(re);
  
      printf("\nString befor removing '%s' : \n%s", re, str);
  
      removeWord(str, re);
  
      printf("\nString after removing '%s' : \n%s", re, str);
  
      return 0;
  }
  
  void removeWord(char *str, char *re) {
      int slen, rlen, found, j;
  
      slen = strlen(str);
      rlen = strlen(re);
  
      for (int i = 0; i &lt;= slen - rlen; i++) {
          found = 1;
          for (j = 0; j &lt; rlen; j++) {
              if (str[i + j] != re[i + j]) {
                  found = 0;
                  break;
              }
          }
          if (str[i + j] != ' ' &amp;&amp; str[i + j] != '\t' &amp;&amp; str[i + j] != '\n' &amp;&amp; str[i + j] !='\0')
              found = 0;
  
          if (found == 1) {
              for (int k = i; k &lt;= slen - rlen; k++)
                  str[k] = str[k + rlen];
  
              slen -= rlen;
              i--;
          }
      }
  }
  </code></pre>