Array not populate properly

I don't know what's going on but my counter isn't looping through. Can someone point me in the right direction?
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 <iostream>
#include <fstream>
#include <string>
using namespace std;

int main()
{
	const int numEmployee = 5;
	string Employees[numEmployee][3];
	double payInformation[numEmployee][2];
	char eStatus[numEmployee];
	double overTimePay, regularPay, netPay;



	ifstream fin("data.txt");

	if (fin.fail())//Check if the file is open
	{
		cout << "File not opened..." << endl;
		return 1;
	}
	while (!fin.eof())
	{
		if (!fin.eof())
		{
			int index;
			index = 0;
			fin >> Employees[index][0] 
				>> Employees[index][1] 
				>> Employees[index][2]
				>> payInformation[index][0]
				>> payInformation[index][1]
				>> eStatus[index];

			index++;

		}
	}
			cout << Employees[0][0] << Employees[0][1]<< endl;

	fin.close();


	system ("PAUSE");
	return 0;
}


When I print [0][0] I get the first name of all the employees instead of only the first one. My counter doesn't seem to be working. Thanks in advance for any advice.
1
2
int index;
index = 0;
Try moving this code outside of the while loop. As it is, you're resetting it to zero every time the loop executes.
Topic archived. No new replies allowed.