fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #define PAT_LEN 5
  5.  
  6. int main()
  7. {
  8. char pattern[] = "<unk>";
  9. char replacement[] = "<raw_unk>";
  10. int c;
  11. int buf[PAT_LEN];
  12. int i, j;
  13.  
  14. for (i = 0; (c = getchar()) != EOF;) {
  15. if (c == pattern[i]) {
  16. buf[i++] = c;
  17. if (i == PAT_LEN) {
  18. printf("%s", replacement);
  19. i = 0;
  20. }
  21. } else {
  22. if (i > 0) {
  23. for (j = 0; j < i; j++) {
  24. putchar(buf[j]);
  25. }
  26. i = 0;
  27. }
  28. putchar(c);
  29. }
  30. }
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0s 4448KB
stdin
<<unk>
stdout
<<unk>