My test file has data like this:
1
2
3
0
1, 2
3, 4
0, 0
4, 3
2, 1
0, 0
How would I separate the data by line but also separate each section of data by the zeros.
ifstream data("testData.txt");
string line, a, b;
while(getline(data,line))
{
stringstream str(line);
istringstream ins;
ins.str(line);
ins >> a >> b;
hold.push_back(a);
hold.push_back(b);
}
How do I separate them by the zeros?
So the lines are significant, and the zero-delimited lists of numbers are also significant? Try something like this:
This isn’t very fault-tolerant, but it works. It relies on a single character (a comma) to be present after every number except the last one on each line.