? P20 Exercise 1-10

来源:互联网 发布:wps办公软件教学 编辑:程序博客网 时间:2024/04/27 22:01
Exercise 1-10. Write a program to copy its input to its output, replacing each tab by \t, eachbackspace by

\b, and each backslash by \\. This makes tabs and backspaces visible in an unambiguous way.


#include <stdio.h>/* replace tabs and backspaces with visible characters */main(){int c;while ((c = getch()) != EOF){if (c == '\t')printf("\\t");else if (c == '\b')printf("\\b");else if (c == '\\')printf("\\\\");else putchar(c);}}


原创粉丝点击