3 ms·
A "word" counter in C++ (not really, but kind of) std::cout << std::distance(std::istream_iterator<std::string>(std::cin), std::istream_iterator<std:::string>(
by butterisgood 2y ago
A "word" counter in C++ (not really, but kind of)
std::cout << std::distance(std::istream_iterator<std::string>(std::cin), std::istream_iterator<std:::string>()) << std::endl;
And I guess you could get "character" count using istreambuf_iterator.
Don't do this :-) (Though I've used it in a pinch)
- butterisgood 2y agoAlso, sorry for the typos... the character version is istreambuf_iterator<char> also... whoops!