I have some problem with my Code.In my code , i want my program can read the file .txt and i finish with that,but for ouput i want can
calculates and displays the amount of each of all words contained therein.Can you help me ?
Right now you're reading data one line at a time. You should read individual words instead:
1 2 3 4
string word;
while (data >> word) {
...
}
Once you have the code working like this, you'll find that it doesn't quite represent a "word" correctly. For example, this will say that "word" and "Word" are different. It will also think that these are all different words:
hello
hello,
hello.
"hello"
Hello
You could fix that problem by writing a function to normalize a word by stripping out punctuation and converting to all upper (or lower) case.