I wrote the following code as part of an exercise in chapter one of K&R. The code replaces tabs and backslashes as expected, but it 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')
        {
            //putchar('\\');
            //putchar('b');
            printf("\\b");
        }
        if (c == '\\')
        {
            putchar('\\');
            putchar('\\');
        }
        if (c != '\t' && c != '\b' && c != '\\')
        {
            putchar(c);
        }
    }
    return 0;
}
I've looked through Stack Overflow. The answers to this question talk about the shell's consuming the backspace, the result being that code I write never sees the backspace. This brings me to my question: what happens to the input I provide at the keyboard? I assume this becomes part of the stdin stream. Clearly, though, not all the characters I enter make it to my code. Can someone please explain what processing happens between my keystrokes and the handling of that input by my code? Also, is there a way for my code to read the stdin buffer before this processing occurs?
I hope these questions make sense. It took me a while to figure out what I am trying to ask, and I'm not sure I've figured that out completely.
 
     
    