From bbf858134ce9a28241fe55c4bf77849c75ab1ced Mon Sep 17 00:00:00 2001 From: Reina Harrington-Affine Date: Thu, 14 Aug 2025 17:27:43 +0000 Subject: [PATCH] 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. --- KNR C/ex1_10.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 KNR C/ex1_10.c diff --git a/KNR C/ex1_10.c b/KNR C/ex1_10.c new file mode 100644 index 0000000..ed4b8c6 --- /dev/null +++ b/KNR C/ex1_10.c @@ -0,0 +1,29 @@ +#include + +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; +}