From 7d26e0ffc7e769b66a14db9c75d45445ae09d716 Mon Sep 17 00:00:00 2001 From: Reina Harrington-Affine Date: Thu, 14 Aug 2025 06:53:38 +0000 Subject: [PATCH] Implementation of exercise 1-9: copying and printing input text to output, removing redundant spaces. --- KNR C/ex1_9.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 KNR C/ex1_9.c diff --git a/KNR C/ex1_9.c b/KNR C/ex1_9.c new file mode 100644 index 0000000..6508533 --- /dev/null +++ b/KNR C/ex1_9.c @@ -0,0 +1,28 @@ +#include + +int main(){ + + int a = getchar(); + int state = 0; + + while (a != EOF){ + + if (state == 1){ + if (a != ' '){ + putchar (a); + } + } else { + putchar(a); + } + + if (a == ' '){ + state = 1; + } else { + state = 0; + } + + a = getchar(); + + } + return 0; +}