datatracker/bin/count.c
Henrik Levkowetz 7ae80407db Tweaked version of count.c
- Legacy-Id: 13514
2017-06-04 16:23:23 +00:00

27 lines
443 B
C

#include <stdio.h>
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 = fgetc(stdin);
while(c != EOF)
{
if (c == '.') count++;
fputc(c, stdout);
fflush(stdout);
if ( count % 76 == 0) {
fprintf(stderr, "%4d", count);
fflush(stderr);
}
c = fgetc(stdin);
}
return 0;
}