Q:

Iterate over ifstream

I know there are a lot of answers already on how to iterate ifstreams but non of them really helped me finding a solution.
My problem is:
I have a txt file containing multiple lines of data. The first line of the txt file tells me how the rest of the data is composed.
for example this is my txt file:
5 5 5
0.5 0.5 0.5
0 0 0
0 0 1
0 0 -1
0.5 1 0
0 0 -1 0
0 0 1 1
0 -1 0 1
1 0 0 3
0 1 0 1
...

so this should tell my program to do
double a,b,c
inf >> a >> b >> c

for the first 5 lines
double a,b,c,d
inf >> a >> b >> c >> d

for the next 5 lines
etc
i guess i might be able to do this by using getLine() and then splitting the resulting String on every " " but i was wondering if there is any 'cleaner' way of doing this.

A:

Why don't you loop?
for(int i = 0; i < 5; i++) {
    double a,b,c;
    inf >> a >> b >> c;
    // Do something with a,b,c
}

for(int i = 0; i < 5; i++) {
    double a,b,c,d;
    inf >> a >> b >> c >> d;
    // Do something with a,b,c,d
}

