From 49a03e32c1f419e98c8886d46c438b3efa859947 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Tue, 16 Nov 2021 19:42:38 +0800 Subject: 1.8 --- 1/8.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 1/8.c (limited to '1') diff --git a/1/8.c b/1/8.c new file mode 100644 index 0000000..400a2de --- /dev/null +++ b/1/8.c @@ -0,0 +1,20 @@ +#include + +/* counts blanks, tabs and newlines in input */ +int main(int argc, char *argv[]) { + int c, bc, tc, nc; + + bc = tc = nc = 0; + + while ((c = getchar()) != EOF) { + if (c == ' ') + bc++; + else if (c == '\t') + tc++; + else if (c == '\n') + nc++; + } + + printf("blanks: %d, tabs: %d, newlines: %d\n", bc, tc, nc); + return 0; +} \ No newline at end of file -- cgit v1.2.3