Hello, I'm reviewing KnR after not having done much programming in about 7 years. I just encountered some behavior I can't quite figure out in the program I made for ex. 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 tabs and backspaces visible in an unambiguous way".)
Can anybody tell me why, when typing "\" & hitting return the output of the code below should be this? (the tab handling statements seem to be just fine)
--------------------------
\
hello feck
----------------------------
Code:
while( (c=getchar()) !=EOF ){
if (c=='\t'){
printf("\\");
printf("t");
}
if (c!='\t'){
if(c=='\\') printf("hello ");{
if(c!='\\') printf("feck ");
}
}
}//while
return 0;
thank you in advance