The command wc
provides lineCount
, wordCount
, and charCount
. I am writing a program that simulates the wc command as it takes a file and spits out the 3 properties. Line count is easy because if it sees \n
it will ++lineCount
and if a char exists and it's not EOF, it will ++charCount
. But what does word mean? What separates words, whitespace?
Asked
Active
Viewed 9,229 times
2

maritaslag
- 23
- 1
- 5
1 Answers
1
This is specified by POSIX:
The wc utility shall consider a word to be a non-zero-length string of characters delimited by white space.
The man page for wc
on my system (Ubuntu 17.04) is similar:
A word is a non-zero-length sequence of characters delimited by white space.

Keith Thompson
- 254,901
- 44
- 429
- 631