summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartin@ashbysoft.com <martin@ashbysoft.com>2022-06-11 20:39:06 +0000
committermartin@ashbysoft.com <martin@ashbysoft.com>2022-06-11 20:39:06 +0000
commit62482c2d0d6b2080d51fe6ea03e2ccd93e3351e0 (patch)
tree11ee49a45d0c4aa87bafe5edf0776ced1e8c20c8
parentc813f7bd522baf1057ba9bee874669ea5b945a66 (diff)
downloadlearn-c-62482c2d0d6b2080d51fe6ea03e2ccd93e3351e0.tar.gz
learn-c-62482c2d0d6b2080d51fe6ea03e2ccd93e3351e0.tar.bz2
learn-c-62482c2d0d6b2080d51fe6ea03e2ccd93e3351e0.tar.xz
learn-c-62482c2d0d6b2080d51fe6ea03e2ccd93e3351e0.zip
ex1-8
-rw-r--r--ex1-8.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/ex1-8.c b/ex1-8.c
new file mode 100644
index 0000000..b692948
--- /dev/null
+++ b/ex1-8.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+int main(void) {
+ int c;
+ uint32_t nl = 0, tb = 0, bl = 0;
+ while ((c = getchar()) != EOF) {
+ if (c == ' ') {
+ bl++;
+ } else if (c == '\n') {
+ nl++;
+ } else if (c == '\t') {
+ tb++;
+ }
+ }
+ printf("nl=%ld tb=%ld bl=%ld\n", nl, tb, bl);
+ return 0;
+} \ No newline at end of file