reading data in columns from a file

hello I am stuck on one of my homework problems. im trying to make the program read a file from my computer then make the file into an array. the code that I have doesn't work at all, I am working on it. my file is in columns that is why I am having problems reading it. so my question is how do I get the program to read the files in columns?


the file data is below

40.0 10.00
38.5 9.50
16.0 7.50
22.5 9.50
40.0 8.00
38.0 8.00
40.0 9.00


the left indicates hours and the right indicates pay rate per employee. I need to somehow read the file so the first line is for employee1 the second for employee2 and so on. so again my question is how do I get the program to read my data in columns?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <fstream>
#include <iomanip> 


using namespace std;

int main()
{
ifstream inputFile;
double	hours,
payrate,
grosspay;
int lines,
    
num_emp;
	
inputFile.open("payroll.dat");		//open the file payroll.dat
	
}
Last edited on
closed account (EwCjE3v7)
1
2
3
4

while (InputFile >> hours >> payrate) {
// other code here
}
Topic archived. No new replies allowed.