Having a problem trying to get this code working. Here's my text file:
Raisin Bran
3.49
300
Milk
1.49
200
White Bread
2.49
100
Butter
2.49
100
Grape Jelly
1.09
50
Here's a part of my code:
inFile >> tempy;
grocery_items[k].set_item_name(tempy);
inFile >> temp;
grocery_items[k].set_item_price(temp);
inFile >> stock;
grocery_items[k].set_qty_on_hand(stock);
For some reason, it only reads the word "raisin" and the numbers after. This is because the first line has two words, not one and my inFile is only doing one word at a time. If I combine the two words into one word, the entire code works fine(for example, Raisin Bran becomes RaisinBran). Is there a way for me to be able to do this without making everything one word?
When I turn the first line into getline(inFile, tempy)
The first line prints, however the numbers just repeat over and over again.