PLEASE HELP!!! Am I doing this correctly???

My basic instructions for my code is to:

Create an array of ints in main()
Pass the array as a parameter to a function to read in the int length data. Making the prototype look like this: void read_data(ifstream& input, int arr[]);
In the read function, read mixed-type input data (using getline() and “cin >>” statements)
In the read function, put the length data into the array
In main, sum up the array of ints
Print their sum

The format of the .txt file I'll be reading is:
James
12
0
1
Kevin
32
2
0
Joe
14
2
1

And I'll have to take the second line of each person (length data) and put them in an array and sum them up in main().

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
48
49
50
51
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

void readData(ifstream& input, int arr[]);

int main()
{
	int myArray[50] = {0}, sumLength;
	ifstream schedule;

	schedule.open ("schedule.txt");

	readData(schedule, myArray);
	schedule.close();

	for (int i = 0; i < 50; i++)
	{
		sumLength = myArray[50] + myArray[i];
	}

	cout << sumLength << endl;

	return 0;
}

void readData(ifstream& input, int arr[])
{
	int tmp;

	if (!input)
	{
		exit(1);
	}

	string line;
	while (!input.eof())
	{
		getline(input, line);
		for (int i = 0; i < 3; i++)
		{
			getline(input, line);
			cin >> tmp;
			cin >> arr[i];
			cin >> tmp;
			cin >> tmp;
		}
	}
}

Anyone? I need help quick please
Topic archived. No new replies allowed.