Problem:
I have a text file with lines of information in it as need below under "txt file". I am attempting to map the items so I can finish my assignment. In mapping them I am using istringstream
. My problem comes about in getting it to work when there are multiple words in an item that I want to have saved in one string. For example the "Unsweetened Applesauce" I want that to be one string (item.setNewItem). Any help would really be appreciative, and since I am a current student, any dumbing down for my sake would really be appreciated. =)
txt file:
1 cup Sugar | 1 cup Unsweetened Applesauce | calorie
Code:
void mapList(ifstream &foodReplace, map<string, Substitutions> &subs)
{
string line;
while (getline (foodReplace, line));
{
Substitutions item;
istringstream readLine(line);
readLine << item.setOldAmount
<< item.setOldMeasurement
<< item.setOldItem
<< item.setNewAmount
<< item.setNewMeasurement
<< item.setNewItem;
subs.insert(pair<string, Substitutions>(item.getOldItem, item));
}
}