I wrote the following code as part of the exercise in the first chapter of K & R. The code replaces tabs and backslashes as expected, but does not replace backspaces with \ b. Here is the code:
#include <stdio.h>
int main(void)
{
int c;
while((c = getchar()) != EOF)
{
if (c == '\t')
{
putchar('\\');
putchar('t');
}
if (c == '\b')
{
printf("\\b");
}
if (c == '\\')
{
putchar('\\');
putchar('\\');
}
if (c != '\t' && c != '\b' && c != '\\')
{
putchar(c);
}
}
return 0;
}
Stack Overflow. , backspace, , , , backspace. : , ? , stdin. , , , , . - , ? , , stdin ?
, . , , , , .