|
|
test1337 wrote: | ||
---|---|---|
How would I go about making a loop to read from a file until I reach a -0? I am wanting to store the first line into a vector and the second line into another vector. Lets say a file is like so, 1 9 6 2 6 3 -0 3 7 6 7 1 8 1 2 3 4 5 6
When I do this, it pushes 3 into vec2. |
vec1
and 3 to vec2
, and you exit the while loop on the next iteration. You should check for 0 right after reading the first number.std::getline
to read a line, and check if it equals "-0". If so, stop. Else extract the two integers from the line, and push them into your vectors, and read the next line, doing the same checks.