Initial incomplete implemenation of exercise 1-10. Current version only reprints tabs to \t and backslashes to \ rather than the intended behavior of doing that in addition to reprinting backspaces as \b. Bug is due to not capturing backspaces as input. Fix pending.
This commit is contained in:
parent
84a9263691
commit
bbf858134c
1 changed files with 29 additions and 0 deletions
29
KNR C/ex1_10.c
Normal file
29
KNR C/ex1_10.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(){
|
||||
int a = 0;
|
||||
|
||||
while (a != EOF){
|
||||
|
||||
a = getchar();
|
||||
|
||||
if (a == '\b' || a == '\t' || a == '\\'){
|
||||
if (a == '\b'){
|
||||
printf("\\b");
|
||||
continue;
|
||||
}
|
||||
if (a == '\t'){
|
||||
printf("\\t");
|
||||
continue;
|
||||
} else {
|
||||
printf("\\");
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
putchar (a);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue