Count characters in input with for loop - C Data Type

C examples for Data Type:char

Description

Count characters in input with for loop

Demo Code

#include <stdio.h>  
  
   int main()  /*from ww w.  j a va2 s. c  om*/
   {  
       double nc;  
  
       for (nc = 0; getchar() != EOF; ++nc)  
           ;  
       printf("%.0f\n", nc);  
   }

Result


Related Tutorials