I take words form a text file and add the words to a map with the key being the words and the value being an int for the number of times the word occurs. My problem is that instead of giving me one ordered map, I have two ordered lists of ordered words in one map. Here is a paste from where it starts ordering again (a-z)
- Science 1
- Spring 1
- Studios 1
- Tally 1
- Test 1
- The 1
- Then 1
- This 1
- Turn 1
- Visual 1
- Write 1
- Your 1
- a 3
- about 1
- an 2
- and 3
- another 1
- are 1
- as 2
- at 1
- available 1
- be 1
- been 1
- by 2
- can 1
- class 3
- code 3
- collection 1
- collection. 1
- correct 1
- cplusplus 1
My code:
string worder;
while (myfile.good())
{
myfile >> worder;
++liner[worder] //liner is a map
}
myfile.close();
//iterate through map
string outfile = "outfile";
ofstream razzleDazzle;
razzleDazzle.open(outfile);
for (auto mapItem : liner){
razzleDazzle << mapItem.first << " " << mapItem.second<< endl;
cout << mapItem.first << " "<< mapItem.second<< endl;
}
//closes output file named "outfile"
razzleDazzle.close();
What gives?