我正在尝试执行 k&r 的 execize 1.10,所以这是:
/*
* 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 tab
* and backspaces visible in an unambiguous way.
*
*/
#include <stdio.h>
int main()
{
int c;
while ((c = getchar()) != EOF) {
if (c == '\t')
printf("\\t");
else if (c == '\b')
printf("\\b");
else if (c == '\\')
printf("\\\\");
else
printf("%c", c);
}
}
gcc -std=c99 1.10.c -o test
如果我用它编译这段代码,\b
如果我使用Backspace. 为什么?以及如何尝试在 Linux中获得\b
压力?Backspace
一个男生跟我说:
您的程序可能看不到该退格键。默认情况下,终端按行缓冲。标准输入也是如此。好吧,stdin 的缓冲是 IDB。