fork download
  1. /* Exercise 1-10: replace tab with \t, backspace with \b and backslash with \\ */
  2.  
  3. #include <stdio.h>
  4. int main()
  5. {
  6. int c;
  7. while( (c=getchar()) != EOF )
  8. {
  9. while( c == '\t' )
  10. {
  11. printf("\\t");
  12. c = getchar();
  13. }
  14. while( c == '\b' )
  15. {
  16. printf("\\b");
  17. c = getchar();
  18. }
  19. while( c == '\\' )
  20. {
  21. printf("\\\\");
  22. c = getchar();
  23. }
  24. putchar(c);
  25. }
  26. }
Success #stdin #stdout 0s 5320KB
stdin
test1	test2\	test3
stdout
test1\ttest2\\	test3