#include <stdio.h>
#define MAX_LEN 60
char *censor(char cens_string[]);

int main() {
  char string_to_censor[MAX_LEN] = "Hello my dear foolish foles!";
  char *cens;
  cens = censor(string_to_censor);
  printf("INPUT:\t %s\n", string_to_censor);
  printf("OUTPUT:\t %s\n", cens);
}

char *censor(char cens_string[]) {
  char to_cens[] = "foo";
  char cens_char = 'x';
  char censored[MAX_LEN + 1], *c, *start;
  c = censored;
  start = c;
  int i = 0;
  // Starting iteration on string to censor
  while (*cens_string) {
    // If we find 'f' char - we need to check current 'f' char and next 2 for
    // equality with to_cens string
    if (*cens_string == to_cens[0] && *(cens_string + 1) == to_cens[1] &&
        *(cens_string + 2) == to_cens[2]) {
      *c = cens_char;
      *(c + 1) = cens_char;
      *(c + 2) = cens_char;
      cens_string += 3;
      c += 3;
    } else {
      *c++ = *cens_string++;
    }
  }
  return start;
}
