|
|
题目是这个
Exercise 1-10. Write a program to copy its input to its output, replacing each tab by \t, each backspace
by \b, and each backslash by \\. This makes tabs and backspaces visible in an unambiguous way.
我想用如下代码实现
- #include <stdio.h>
- /* copy input to output; 2nd version */
- main()
- {
- int c;
- while ((c = getchar()) != EOF)
- {
- if (c == '\t')
- {
- putchar('\\');
- c='t';
- }
- else
- if(c == '\b')
- {
- putchar('\\');
- c='b';
- }
- else
- if(c == '\\')
- {putchar('\\');
- c='\\';
- }
- putchar(c);
-
- }
- }
复制代码
不知为什么,只有\b不行。在此请教。 |
|