Create a program that counts the number of characters in its input up to the end of file. - C Language Basics

C examples for Language Basics:Console

Description

Create a program that counts the number of characters in its input up to the end of file.

Demo Code

#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;  
}

Related Tutorials