mardi 23 janvier 2018

How to create containers from categorized lists in a txt file?

I’m trying to take a list, like a grocery list for example, that would be in a text file that looks something like

Household

Wipes 3 Toilet paper 6

Food

Avacados 4 Cheese 2 Bread 5

From these categorized lists, I wish to create some sort of data container (I was thinking vectors, or maps) for each different category on the list. I was hoping that each map or vector could be named the category it came from, and include the items and quantities listed under it to be accessed later. I assumed this would be done using an ifstream iterator, maybe peeking at the next line, but I’m confused on the syntax that would catch the next keyword to start a new data container. Thanks!

Aucun commentaire:

Enregistrer un commentaire