C examples for Language Basics:Console
Create a program that counts the number of characters in its input up to the end of file.
#include <stdio.h> int main(void) { //from w ww . jav a2 s.co m int ch; int ct = 0; while ((ch = getchar()) != EOF) ct++; printf("%d characters read\n", ct); return 0; }