> counts[CHAR_MAX - CHAR_MIN]
Shouldn't that be counts[CHAR_MAX - CHAR_MIN + 1] ?
Good catch, thanks!
That's cool and I agree about the advantages you mention.
In your code \n must be a line separator rather than a line terminator. (Otherwise, if the last line is \n terminated, the function returns 0.)
* Faster
* No allocations
* No dependencies
* Easy to add an early return if common == 0 (in the functional version it's much harder)