determining array size from file input

so i have a file which the first line reads: x y
where x is the number of students
and y is the number of courses

e.g. 20 4

how can you extract the data and make it into an array size?

1
2
3
4
5
6
7
8
int x[];
int y[];

ifstream grades;
grades.open("grades.txt");

getline(grades, line1);
1
2
3
4
5
6
int size = stoi(line1);//Presuming you get size of array from a file
/* or just
grades >> size; 
*/
int* x = new int[size];
x[0] = 1;//use array as you want 
what if ... grades >> sizex >> sizey;
how would you extract for y ?
Last edited on
Topic archived. No new replies allowed.