Hello, I have the following working code. It creates a text file with words and count the number of occurencies of identical words. The function "countWords" count this (line 10 - 17). And this function uses string and must to count the number of occurencies of identical STRINGS. But if our input
Notice that the istream extraction operations use whitespaces as separators; Therefore, this operation will only extract what can be considered a word from the stream. To extract entire lines of text, see the string overload of global function getline.
Elsewhere:
Extracts characters from is and stores them ..., stopping as soon as ... a whitespace character is encountered
Internally, the function accesses the input sequence by first constructing a sentry object (with noskipws set to false).
noskipws==false means same as skipws==true
skipws ... leading whitespaces are discarded before formatted input operations.
In other words:
1. You std::getline entire line into a string.
2. You write that string into a file.
3. You read one "word" at a time from the file with the >>