Assignment help.

I'm having some serious issues really understanding this question. Does he want me declare the variables in main and reference them to input? Maybe I'm just not understanding it correctly.

Program requirements:
Your program must include a function named ReadInputRecord that has 8 reference arguments. The function should read a single line of the input file and return the data in the reference arguments. One of the reference arguments is the input file object.

Your program must include a function named WriteOutputRecord that has 4 value arguments and 1 reference argument (reference to the output file object). The four value arguments should contain the data to write to the output file.

Your program should open the file “RawScore.dat” for input and “ComputedScore.dat” for output . Do not specify a path when opening your file.

Your program must display an error message if there is an error opening the input or output file. No other output should be displayed on the screen. Your program must also close the input and output files when they are no longer needed.

You don’t have to do any error checking on the input file.

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
int main()
{
	int num1, num2, num3, num4, num5, num6;
	string team;
	ifstream rawdata;
	ofstream output("output.dat");
	rawdata.open("RawScore.dat");
        void ReadInputRecord(int&, int&, int&, int&, int&, int&, string&, ifstream &);


	//static int TIME_PENALTY = 1200;

}
	void ReadInputRecord(int &num1, int &num2, int &num3, int &num4, int &num5, int &num6, string &team, ifstream &rawdata)
	{
		
		while (rawdata >> num1)
		{

			rawdata >> num2;
			rawdata >> num3;
			rawdata >> num4;
			rawdata >> num5;
			rawdata >> num6;
			rawdata >> team;
			//cout << num1 << num2 << num3 << num4 << num5 << num6 << team << "\n";
		}

		
		
	}
Last edited on
Does he want me declare the variables in main and reference them to input?

Yes.

You do declare the variables in main and that is correct.

However, your line 8 is a declaration of function ReadInputRecord. It should not be in the main. It should be before main. The main should call the function.

Furthermore, the ReadInputRecord should read one record (i.e. line) only. Yours does read the whole file.
Topic archived. No new replies allowed.