Count characters in input with while loop - C Data Type

C examples for Data Type:char

Description

Count characters in input with while loop

Demo Code

#include <stdio.h>  


int main()//  w ww  .jav  a 2s .  co m
{
   long nc;

   nc = 0;
   while (getchar() != EOF)
      ++nc;
   printf("%ld\n", nc);
   return 0;
}

Result


Related Tutorials