在C语言学习过程中,需要输入回退符,比如C程序设计语言的习题
练习 1-10 编写一个将输入复制到输出的程序,并将其中的制表符替换为\t,把回退符替换为\b,把反斜杠替按为\\。这样可以将制表符和回退符以可见的方式显示出来。
Windows系统:输入CTRL+H
Linux/Unix/Mac系统:输入CTRL+H
#include
main()
{
int c;
while( (c = getchar()) != EOF){
if(c == '\t')
printf("\\t");
else if(c == '\b')
printf("\\b");
else if(c == '\\')
printf("\\\\");
else
putchar(c);
}
}
[root@localhost c]# ./a.out
hello,-^Hworld!
hello,-\bworld!