Getting the word count of a file

This is a discussion on Getting the word count of a file within the C++ Programming forums, part of the General Programming Boards category; Is there any way to get the total number of words that is in a text file without looping through ...

Getting the word count of a file

Is there any way to get the total number of words that is in a text file without looping through each line and breaking it down into words and keeping track of that number with a counter variable? Something like dividing the size of the file with the size of a string?