Hi, im trying to make a text based monopoly game and im trying to read in a text file that's contents are laid out like this:
GO
Red Road 60 5 0
Red Street 80 10 0
Bonus
Gray Road 100 15 1
Gray Street 120 15 1
and so on...
The numbers are the cost of landing on them, but what ive been trying to fiqure out is how can i split these lines up and put them into different variables in a class, ive been using getline so far which has worked with splitting up the lines indivually but i need to split the actual lines up now, ive also been using "squaresTextFile >> squareName[i] >> squareCost[i];" this splits the name up though since there is a space between "red" and "road", does anyone know how i can go about doing this?
Delimit your file with a specific character that doesn't appear any where else in the data file. Comma's or tab's are a popular choices for this. Then you can have a lambda like this:
1 2 3 4 5
auto NextTab = [&] (std::string& Var)
{
Var = Input.substr(0, Input.find('\t'));
Input = Input.substr(Var.length() + 1, std::string::npos);
};