Read multiple columns of data

Hi all,

I am trying to rad some data from txt which has the following form:

3
6
2
1 4
2 4
3 4
4 2
5 4
6 1

The first row is for NumA, the second is NumN, the third is K, and the remaining 6 rows in the first column goes to c array, and in the second column I have x array.

This is what I got so far:
1
2
3
4
5
6
7
8
9
10
11
12
13
      int c[NumA];
      int x[NumA];

      ifstream file("dataC.txt");


      for(int a = 0; a < NumA; a++ ){
          file >> NumA;
          file >> NumN;
          file >> K;
          file >> c[a];
          file >> x[a];
      }


How would you modify this code to store these data in these arrays and integers?

Thanks!
Lines 8 through 10 belong outside the loop, before line 7.
Topic archived. No new replies allowed.