counts number of lines in input: - C Data Type

C examples for Data Type:char

Description

counts number of lines in input:

int ch, count = 0;
while((ch = getchar()) != EOF)
   if(ch == '\n')
      ++count;
printf("%d\n", count);

Related Tutorials