Reading test scores only from input file

I have to write a program that reads a file consisting of students test scores. I have to use arrays for this part, but can't really see how to implemented in a file. If I weren't suppose to use a file then I would have this problem tackled but since file has to be used, how to do I do this. I worked on this code, but I know there will be several tweaks :(

1
2
3
4
5
6
7
8
9
 void readingtestscores (ifstream &in, ofstream & out,int testscores[],int size)
{
	while (in>>testscores)

		for (int row=0;row<size;row++)
			in>>testscores[row];

}
65
78
67
46
45
34
23
57
78

The input file will be like this. My problem is that I don't know the size of the array. What if I add more test scores in the file. Then the array would change constantsly.Also, I haven't covered pointers yet. I'm a just a beginner. under the section of arrays.
What are you actually trying to do with the scores? Just have them stored in an array?
Well that's how the input data should look like. basically, I want the user to enter in a test score in each line according to my assignment. I want each test score to be stored in an array, but I don't what the size of array is, thus making it difficult for me to understand how to construct this code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
void studenttestreader (int testscores[],int size,ofstream &out, ifstream&in)
{
	//Total number of students not defined. There would be less then 50 though. So have numberofstudents declared to 0;
	int numberofstudents=0;

	in>>testscores[numberofstudents];

	//while file is open

	while (in>>testscores[numberofstudents] && size<=50)
	{
		in>>testscores[numberofstudents];
		out<<testscores;
	
	
	
	}
	
	



}


Ok so I worked on my code for a little while and believe I have set it up correctly. Ratham or any forum members. Can the members look over this and see if this would be correct of not :). I didn't know the size of the array before. So what I did was declared numberofstudents to zero which will increment each tim ethere is a test score inputted. We know the class will have less then 50 students so I made size<=50. Would this be a right approach?
Knock knock...anyone there
Topic archived. No new replies allowed.