From 7ae80407db1b252112685b89e34b6e8f85c15103 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Sun, 4 Jun 2017 16:23:23 +0000 Subject: [PATCH] Tweaked version of count.c - Legacy-Id: 13514 --- bin/count.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/count.c b/bin/count.c index 76aeded4d..52f531d66 100644 --- a/bin/count.c +++ b/bin/count.c @@ -10,15 +10,17 @@ int main( void ) setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); - c = getchar(); + c = fgetc(stdin); while(c != EOF) { if (c == '.') count++; - putchar(c); + fputc(c, stdout); + fflush(stdout); if ( count % 76 == 0) { fprintf(stderr, "%4d", count); + fflush(stderr); } - c = getchar(); + c = fgetc(stdin); } return 0; }