Skip to content

Commit ed1e9cd

Browse files
committed
A tiny utility to count test dots and periodically report the count.
- Legacy-Id: 13512
1 parent 08f134b commit ed1e9cd

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

bin/count.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <stdio.h>
2+
3+
int main( void )
4+
{
5+
int c;
6+
int count = 0;
7+
8+
//turn off buffering
9+
setvbuf(stdin, NULL, _IONBF, 0);
10+
setvbuf(stdout, NULL, _IONBF, 0);
11+
setvbuf(stderr, NULL, _IONBF, 0);
12+
13+
c = getchar();
14+
while(c != EOF)
15+
{
16+
if (c == '.') count++;
17+
putchar(c);
18+
if ( count % 76 == 0) {
19+
fprintf(stderr, "%4d", count);
20+
}
21+
c = getchar();
22+
}
23+
return 0;
24+
}

0 commit comments

Comments
 (0)