Question : iteration

HI there,
I have this code below and If I want to read two columns should I rpeate pice of it couple times and 3,4,..and so on as
well.
how can I avoid this repeat when I read n columns.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
QTextStream in(&file);
    double data[100][2];
    for(int i=0 ;i<100;i++)
    {
        double x,y;
        QString content;
        QString content1;
        in >> x >> y;
        content = content.setNum(x);
        content1=content1.setNum(y);
        data[i][0]=content.toDouble();
        data[i][1]=content1.toDouble();
        in.readLine();
    }

Answer : iteration

Insert code in place of the internal column read and assignment.



1:
2:
3:
4:
5:
6:
for (int k = 0; k < NUMBER_OF_COLUMNs; k++) {
double x;
in >> x;
QString qs;
data[i][k] = qs.setNum(x).toDouble();
}
Random Solutions  
 
programming4us programming4us