From 72093b72328dd9e60eb882e9cd3d910f2fa72027 Mon Sep 17 00:00:00 2001 From: Kris Lamoureux Date: Fri, 5 Nov 2021 21:29:39 -0400 Subject: [PATCH] Character counting example --- 05-char-counting.c | 11 +++++++++++ Makefile | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 05-char-counting.c diff --git a/05-char-counting.c b/05-char-counting.c new file mode 100644 index 0000000..ebecc04 --- /dev/null +++ b/05-char-counting.c @@ -0,0 +1,11 @@ +#include + +int main() +{ + long nc; + + nc = 0; + while (getchar() != EOF) + ++nc; + printf("%ld\n", nc); +} diff --git a/Makefile b/Makefile index e70c2c4..e60db29 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -all: hello mathvars c2f input +all: hello mathvars c2f input count hello: 01-hello-world.c gcc -o ./bin/01-helloworld 01-hello-world.c @@ -12,5 +12,8 @@ c2f: 03-celsius-to-fahrenheit.c input: 04-file-copying.c gcc -o ./bin/04-input 04-file-copying.c +count: 05-char-counting.c + gcc -o ./bin/05-count 05-char-counting.c + clean: $(RM) ./bin/*-*