i was trying to do the execize 1.10 of k&r so this is :
/*
* 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);
}
}
If i compile this code with gcc -std=c99 1.10.c -o test
it doesn't print \b
if i use Backspace. Why? And how I could try to get \b
pressing Backspace in Linux ?
A guy has said me:
Your program probably doesn't see that backspace. Terminals buffer by line, by default. So does stdin. Well, stdin's buffering is IDB.