I am trying to solve this K&R question. I tried this code in CodeBlocks.
int main()
{
int c, d;
while ( (c=getchar()) != EOF)
{
d = 0;
if (c == '\\')
{
putchar('\\');
putchar('\\');
d = 1;
}
if (c == '\t')
{
putchar('\\');
putchar('t');
d = 1;
}
if (c == '\b')
{
putchar('\\');
putchar('b');
d = 1;
}
if (d == 0)
putchar(c);
}
return 0;
}
But when i press backspace \b is not being displayed in place of that.

Please help me.
It’s because the console window handles keyboard and editing keys itself.
You have to look into the Windows console functions, especially the
SetConsoleModefunction.To clear the
ENABLE_PROCESSED_INPUTandENABLE_LINE_INPUTflags:Note: The above code is not tested, as I don’t have access to a Windows machine.