From 2c345e0909a082b77be959a4e6166cdbdc79e067 Mon Sep 17 00:00:00 2001 From: Adam Carpenter <53hornet@gmail.com> Date: Fri, 10 May 2019 16:00:12 -0400 Subject: Init. --- counter.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 counter.c (limited to 'counter.c') diff --git a/counter.c b/counter.c new file mode 100644 index 0000000..a1b9927 --- /dev/null +++ b/counter.c @@ -0,0 +1,29 @@ +#include + +/* + * Count characters in input; 1st version + */ +//main() { +// long nc; +// +// nc = 0; +// +// while (getchar() != EOF) +// ++nc; +// +// +// printf("%ld\n", nc); +//} + +/* + * Count characters in input; 2nd version + */ +main() { + long nc; + + + for (nc = 0; getchar() != EOF; ++nc) + ; + + printf("%ld\n", nc); +} -- cgit v1.2.3