diff options
Diffstat (limited to 'counter.c')
-rw-r--r-- | counter.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/counter.c b/counter.c new file mode 100644 index 0000000..a1b9927 --- /dev/null +++ b/counter.c @@ -0,0 +1,29 @@ +#include<stdio.h> + +/* + * Count characters in input; 1st version + */ +//main() { +// long nc; +// +// nc = 0; +// +// while (getchar() != EOF) +// ++nc; +// +// +// printf("%ld\n", nc); +//} + +/* + * Count characters in input; 2nd version + */ +main() { + long nc; + + + for (nc = 0; getchar() != EOF; ++nc) + ; + + printf("%ld\n", nc); +} |