counts number of characters in input: - C Data Type

C examples for Data Type:char

Introduction

Using for loop


double count;
for(count = 0; getchar() != EOF; ++count)
     ;                                               /* null statement */
printf("%.0f\n", count);

Using while loop

long count = 0;
while(getchar() != EOF)
   ++count;
printf("%ld\n", count);

Related Tutorials