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:
Reina Harrington-Affine 2025-08-14 17:27:43 +00:00
parent 84a9263691
commit bbf858134c

29
KNR C/ex1_10.c Normal file
View 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;
}