Need help with importing a .dat file

Any time I run this program I get debug errors saying one of my array variables is corrupted.

Here is the contest.dat file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
100		16.333		36.101
101		18.581		46.1304
102		5.1719		53.1723
103		8.2512		57.87
104		17.3333		47.1318
105		13.9204		57.9003
106		13		35.922
107		16.754		33.9803
108		12.25		40.02
109		5.3333		30.6334
110		12.5		43.7502
111		16.5		32.569
112		8.668		50.5791
113		17.67		30.081
114		9.8289		51.3
115		18.4203		48.827
116		10.082		48.9
117		16.42		57.81
0		-1.0		-1.0


Here is my program:

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
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

#define MAX_SIZE 50


int main()
{
	 char filename[80];
     ifstream contestFile;

     cout << "What is the name of the file containing the contest results? ";
     cin >> filename;
     contestFile.open(filename); 
     if(contestFile.fail())        
     {                   
        cout << "File not found. Program terminated." << endl;
        return 1;
     }



	int contestantID[MAX_SIZE];
	double feetOfTossDistance[MAX_SIZE], minutesOfRaceTime[MAX_SIZE];
	int size = 0;

	 contestFile >> contestantID[MAX_SIZE];
     while (contestantID[MAX_SIZE] != 0)
     {
          contestFile >> feetOfTossDistance[MAX_SIZE] >> minutesOfRaceTime[MAX_SIZE];
          size++;
          contestFile >> contestantID[MAX_SIZE];
     }
     contestFile.close();

	for(int i = 0; i < size; i++) 
		cout << setw(5) << contestantID[i] << setw(10) << feetOfTossDistance[i] << setw(10) <<  minutesOfRaceTime[i] << endl;
	

	return 0;
}


Any help on getting the program to work properly would be much appreciated.
contestFile >> contestantID[MAX_SIZE];

valid indices for arrays are 0 to size-1.
Topic archived. No new replies allowed.