.txt to 2D Array: Extra values outputted, shouldn't create trace.

I've triple-checked, the amount of rows and columns of the .txt is definitely 17 columns and 105 rows. There is something wrong with the storing of the values into the 2D array but I can't see it.

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
string values[17][105];
ifstream stats("Stats.txt");
int a = 0;
int b = 0;
if(!stats)
{
	cout<<"Error opening file."<<endl;
	system("pause");
	return -1;
}

while(!stats.eof())
{
	getline(stats,values[a][b],' ');
	if(a == 16)
	{
		a=0;
		b++;
		getline(stats,values[a][b],' ');
	}

	a++;
}

cout << values[0][0] << " \n";
cout << values[1][0] << " \n";
cout << values[2][0] << " \n";
cout << values[3][0] << " \n";
cout << values[4][0] << " \n";
cout << values[5][0] << " \n";
cout << values[6][0] << " \n";
cout << values[7][0] << " \n";
cout << values[8][0] << " \n";
cout << values[9][0] << " \n";
cout << values[10][0] << " \n";
cout << values[11][0] << " \n";
cout << values[12][0] << " \n";
cout << values[13][0] << " \n";
cout << values[14][0] << " \n";
cout << values[15][0] << " \n";
cout << values[16][0] << " \n";

1
2
...
cout << values[15][0] << " \n";

When I end with this line, it outputs 16 correct values in correct order from the first row.

1
2
...
cout << values[16][0] << " \n";

But ending at this line, it outputs 18 correct values all in correct order with the last one being the value that starts the next line. It should just end at the 17th value - the end of the line.

1
2
...
cout << values[0][16] << " \n";

Then when I invert to make it output the first hand column it does a trace through the array, outputting what should be [0][0], [1][1], [2][2], etc. Due to 16, it traces to end with the start of the 18th line.

1
2
...
cout << values[0][15] << " \n";

Using [0][15] traces to end on the 16th row.

1
2
...
cout << values[1][15] << " \n";

Offsets the trace to the right by one.

Thanks in advance.
I still can't figure this out. Help anyone?
Topic archived. No new replies allowed.