When I read the C Programming Language and do the exercise 1-10, there is a problem made me puzzled.
It's said that when I enter a backspace, the character is processed by the console driver and not delivered to the program, so what I can do is create a file with embedded backspace.However, it's seemed useless no matter I directly enter '\b' or press Ctrl + H.
When I press Ctrl + H, the screen will show "\b", but when I run the program, it seems that the program will still see it as two characters '\' and 'b'. No matter what I enter, it never shows "\backspace" when I run the program.
What should I do to make the program recognize it as a character of backspace?
My codes are like following:
#include <stdio.h>
int main()
{
int c;
while((c=getchar())!=EOF){
if(c=='\t')
printf("\\t");
else if(c=='\\')
printf("\\\\");
else if(c=='\b')
printf("\\backspace");
else
putchar(c);
}
}