This program copy its input to its output, replacing TAB(\t
) by \t
backspace(\b
) by \b
.
But here in my code I am unable to read input character when I enter backspace its not replacing as a tab works .
Compiling with GCC in Linux:
#include<stdio.h>
int main(void)
{
int c=0;
while((c=getchar())!=EOF){
if(c=='\t'){
printf("\\t");
if(c=='\b')
printf("\\b");
}
else
putchar(c);
}
return 0;
}
Suppose if I type vinay (tab) hunachyal
Output:vinay\thunachyal
If I type vinay(and 1 backspace)
Output:vina
So my query is why vina\b
is not printing in this case?
Is it possible to detect \b
and print \b
? if not whats the reason
Note:
I need at run time input backspace not providing separate file having \b