From 7be84d6b8803ad0e98e05e81a2e494630edccc48 Mon Sep 17 00:00:00 2001 From: Reina Harrington-Affine Date: Wed, 13 Aug 2025 07:15:47 +0000 Subject: [PATCH] Complexted exercise 1-8; count and report number of newline, tab, and blank characters in input. --- KNR C/ex1_8.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 KNR C/ex1_8.c diff --git a/KNR C/ex1_8.c b/KNR C/ex1_8.c new file mode 100644 index 0000000..aa2a727 --- /dev/null +++ b/KNR C/ex1_8.c @@ -0,0 +1,19 @@ +#include + +int main(){ + + int a = getchar(); + int counter = 0; + + while (a != EOF){ + if (a == '\n' || a == '\t' || a == ' ') + ++counter; + + a = getchar(); + } + +printf("%d", counter); + +return 0; + +}