From ed1e9cd8db80495c0d07b73a8475e8a2985db070 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Sun, 4 Jun 2017 15:28:03 +0000 Subject: [PATCH] A tiny utility to count test dots and periodically report the count. - Legacy-Id: 13512 --- bin/count.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 bin/count.c diff --git a/bin/count.c b/bin/count.c new file mode 100644 index 000000000..76aeded4d --- /dev/null +++ b/bin/count.c @@ -0,0 +1,24 @@ +#include + +int main( void ) +{ + int c; + int count = 0; + + //turn off buffering + setvbuf(stdin, NULL, _IONBF, 0); + setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stderr, NULL, _IONBF, 0); + + c = getchar(); + while(c != EOF) + { + if (c == '.') count++; + putchar(c); + if ( count % 76 == 0) { + fprintf(stderr, "%4d", count); + } + c = getchar(); + } + return 0; +}