determining array size from file input
Apr 16, 2013 at 9:05am UTC
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);
Apr 16, 2013 at 9:16am UTC
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
Apr 16, 2013 at 9:26am UTC
what if ... grades >> sizex >> sizey;
how would you extract for y ?
Last edited on Apr 16, 2013 at 9:27am UTC
Topic archived. No new replies allowed.