TheQuack45

K&R C Language -- Exercise 1-10

May 31st, 2016
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. /* Copy input to output, replace specials with escape sequences */
  4. main()
  5. {
  6.     int c;
  7.    
  8.     while ((c = getchar()) != EOF) {
  9.         if (c == '\t') {
  10.             printf("\\t");
  11.         } else if (c == '\b') {
  12.             printf("\\b");
  13.         } else if (c == '\\') {
  14.             printf("\\\\");
  15.         } else {
  16.             putchar(c);
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment