Output file values in two different arrays?

How do I go about putting the values below into an angleArray (left column numbers), and a liftArray (right column numbers).

integers1.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-4 -0.182
-2 -0.056
0 0.097
2 0.238
4 0.421
6 0.479
8 0.654
10 0.792
12 0.924
14 1.035
15 1.076
16 1.103
17 1.120
18 1.121
19 1.121
20 1.099
21 1.099
21 1.059


Here's the code so far
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

void countInts(ifstream& infile); // Count total int from .dat file

int main () {
    string line;
    ifstream myfile ("integers1.txt");
    // get length of file:
    myfile.seekg (0, ios::end);
    int length = myfile.tellg();
    myfile.seekg (0, ios::beg);
    if (myfile.is_open())
    {
        while ( myfile.good() )
        {
            getline (myfile,line);
            cout << line << endl;
            
            for(int i=0; i < length; i++){
                
                
            }
        }
        
        myfile.close();
    }
    
    else cout << "Unable to open file"; 
    
    return 0;
}


Right now it displays the file by line.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <fstream>

using namespace std;


int main()
{
	double left[1000], right[1000];
	int lpos = 0, rpos = 0;

	for(ifstream fin("integers1.txt"); fin >> left[lpos++] >> right[rpos++]; );
	lpos--; rpos--;

	for(int i = 0; i < lpos; cout << left[i++] << " ");
	cout << endl << endl;
	for(int i = 0; i < rpos; cout << right[i++] << " ");

	return 0;
}
Works like a charm. Thank you!!!
Topic archived. No new replies allowed.