| 1 | #include <stdio.h> |
| 2 | #include <unistd.h> |
| 3 | |
| 4 | /* |
| 5 | * This program does two things: |
| 6 | * |
| 7 | * - It converts <TAB> characters into backslashes '\' |
| 8 | * - It converts <lf> (10) line end characters to <cr> (13) |
| 9 | * |
| 10 | */ |
| 11 | |
| 12 | #define INPUT_TAB 0x09 |
| 13 | |
| 14 | int main (int argc, char **agrv) |
| 15 | { |
| 16 | char c; |
| 17 | while (read (0, &c, 1)) { |
| 18 | switch (c) { |
| 19 | case INPUT_TAB: |
| 20 | printf ("\\"); |
| 21 | break; |
| 22 | case '\n': |
| 23 | printf ("\r\n"); |
| 24 | break; |
| 25 | default: |
| 26 | printf ("%c", c); |
| 27 | break; |
| 28 | } |
| 29 | } |
| 30 | return 0; |
| 31 | } //main() |
| 32 | // Ende. |