so I'm trying to output 2 different text files, one has customer names and the other has items they are selling. I gave each customer an ID and each of their items has the same ID. Only problem is when I try to output it, it only outputs the first item with the same ID. I do not want to display the ID number at all, I think getline would show it so I am not using it.
John Smith johnsmith@mail.com
shoes $12
shirt $15
Guy Smith guysmith@mail.com
phone $50
....
here is what I actually get
John Smith johnsmith@mail.com
shoes $12
Guy Smith guysmith@mail.com
phone $50
The first customer shirt item isn't being outputted. Maybe I'm reading the or comparing the info wrong or just not seeing it, any help would be appreciated, thanks!
Make first customer have three items and you will got more serious problem.
You need to change whole logic here. You best bet is to read all info from files into some container(s) and then manipulate them. You might use, say std::map<int, std::pair<customer, std::vector<item>>>, where int will be an ID and customer and item is respective structs.