From 49891f6bce29843f503b437c84d83cb787ecfa87 Mon Sep 17 00:00:00 2001 From: Zhineng Li Date: Sat, 10 Jan 2026 16:37:39 +0800 Subject: first commit --- ch01/ex08-count.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 ch01/ex08-count.c (limited to 'ch01/ex08-count.c') diff --git a/ch01/ex08-count.c b/ch01/ex08-count.c new file mode 100644 index 0000000..c5052e6 --- /dev/null +++ b/ch01/ex08-count.c @@ -0,0 +1,22 @@ +#include + +/* count blanks, tabs, and newlines in input */ +int main() +{ + int c; + int ns, nt, nl; + + ns = 0; + nt = 0; + nl = 0; + + while ((c=getchar()) != EOF) { + if (c == ' ') + ++ns; + if (c == '\t') + ++nt; + if (c == '\n') + ++nl; + } + printf("%d %d %d\n", ns, nt, nl); +} -- cgit v1.2.3