[prev] [index] [next]

Exercise: Count lines in stdin

Write a program that
  • reads text from its standard input
  • counts the number of lines in the text
  • displays this as a single number
  • a line is anything that ends with '\n'