13
Count the number of characters read
- #include <stdio.h>
- main() {
- long count;
- for ( count = 0L; getchar() != EOF; ++count )
- ; /* empty */
- printf("%ld\n", count);
- }
$ gcc -o ccount ccount.c
$ ./ccount
one two three four five six seven
eight nine
ten
49
^D
$ ./ccount < ccount.c
133
Comments