Reading from file to array

I am new to c++ and am unsure how to read from a file with an unspecified amount of entries into 3 arrays, the file will look like this:

Name Wage(double) Hours worked(int)





I dont know how to read the first column into one array and the next column into a different one and the last into a different one.
Last edited on
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
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;

int main()
{
	ifstream infile("in.txt");
	vector<string> name;
	vector<double> wage;
	vector<int> hours;
	string tname;
	double twage;
	int thours;
	while(true)
	{

		if(infile.eof()) break;
		infile >> tname >> twage >> thours;
		name.push_back(tname);
		wage.push_back(twage);
		hours.push_back(thours);
	}
	return 0;
}
Topic archived. No new replies allowed.