Hello everyone
I have a txt file which contains 150 lines.Each line has the student-id and then the grades from 6 lessons like below >>>>
1523 5 7 6 7 3 9
1524 7 4 9 10 3 6
....
....
.....
I want to create a method that will read the file and will save this data in 2 arrays. The first array will be ID[150] in which will be stored the id's of each student and the second array will be GRD[6][150] in which will be saved the 6 grades of each student.
I've created a method to do this work but when im tryin to check the arrays i don't get to correct values in the correct places.
my code is this:
Now if you try to check the content of the arrays you will realize that the id's aren't in possitions ID[0]=1523, ID[1]=1524.......... neither the grades!
can you help me?
Thanks a lot!!
I have a txt file which contains 150 lines.Each line has the student-id and then the grades from 6 lessons like below >>>>
1523 5 7 6 7 3 9
1524 7 4 9 10 3 6
....
....
.....
I want to create a method that will read the file and will save this data in 2 arrays. The first array will be ID[150] in which will be stored the id's of each student and the second array will be GRD[6][150] in which will be saved the 6 grades of each student.
I've created a method to do this work but when im tryin to check the arrays i don't get to correct values in the correct places.
my code is this:
Rich (BB code):
unsigned int getData(ifstream& f, unsigned int* ID,float** GRD)
{
unsigned int j=0;
f>>ID[j];
while ((j<150) && (!f.eof()))
{
for (unsigned int i=0; i<6; i++)
f>>GRD[j];
j++;
f>>ID[j];
}
return j;
}
int main() {
unsigned int ID[150],col;
float GRD[6][150],*k[6];
ifstream f;
for (int i=0; i<6;i++)
k = &B[0];
f.open("myFile.txt");
if (f.fail())
cout<<"File not found!";
else
col = getData(f,AM,k);
}
Now if you try to check the content of the arrays you will realize that the id's aren't in possitions ID[0]=1523, ID[1]=1524.......... neither the grades!
can you help me?
Thanks a lot!!