Reading from files please help!

Hi, Basically I have a file that has numbers in and i need them to be read into my code ( which i thought i had done correctly) but it doesnt seem to be happening. The numbers are displayed in 2 collumns. Once read they need to be used in the calculation and outputted onto the screen I am having alot of difficulty with this can any one help? The numbers in the file go like this
4
3 2
5 7


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
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main()
{

	ifstream in_file;
	ofstream myfile;
	
	int rm = 500;

	myfile.open("Results.txt");
	in_file.open("account", ios::out);

	while(!in_file.eof())
{ 
	string x;
	float numberneeded = 0;
	float a = 0, b = 0;

	std::getline(in_file,x);
	in_file >> numberneeded;

	float fullamount = 0;

	for(int i=0; i < numberneeded; i++)
{
		float payslip;
		in_file >> a >> b;
		payslip = a*b;
		fullamount = payslip;
		cout >> fullamount;


}
in_file.ignore();


int exit;

	system("pause");
	return 0;
}
Last edited on
Topic archived. No new replies allowed.