Arrays

I am writing a program for a class in which i need to to read and display quiz scores from a textfile. The text file has score records for students and is organized in a table. There are 20 students in the entire class and each has 10 scores. The table is tab delimited and has the dimension of 20 by 10. Each row in the table has 10 scores from a student. Each column in the table has 20 scores, each for a student. Each score is between 1 and 100. The file name is score.txt.

This is what I have so far, and I keep getting an error on my my arrays, and I am not sure how to fix it.

Any help or suggestions would be appreciated!!


#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int scores;
int students;
fstream score_file;
score_file.open( "score.txt", ios::in );
if (! score_file)
{
return 1;
}
score_file >> scores;
cout << scores << endl;

int scores [10];
int students [20];

for ( int student =0; students <20; student ++);
for ( int scores =0; scores < 10; scores ++);

int scores [students][scores];
}

cout << endl;
}



score_file.close();
return 0;
}

The compiler is confused by the same name being defined as different things - e.g. as regular integer variables and also as arrays. Do you mean to have a 2d array?

1
2
3
4
5
int scores;
int scores [10];
int scores [students][scores];
int students;
int students [20];



Remove the semicolon at the end of the for statements.
for ( int student =0; students <20; student ++);

You also have a couple of closing } with no corresponding opening {
Topic archived. No new replies allowed.