Word Count

December 8, 2009

The unix wc command counts the lines, words and characters in a file; the Unix V7 man page is shown below:


    wc -- word count


    wc [ -lwc ] [ name ... ]


    Wc counts lines, words and characters in the named files,
    or in the standard input if no name appears. A word is a
    maximal string of characters delimited by spaces, tabs or

    If the optional argument is present, just the specified
    counts (lines, words, or characters) are selected by the
    letters l, w or c.

Your task is to implement the unix wc command. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Pages: 1 2


Get every new post delivered to your Inbox.

Join 697 other followers