I need to read data from a file into an array of structures, here is my code — I recognize the length of the file (the number of lines) and then read it, but I do not get what I need at the output, what's the problem?
int countLine = 0; string line; ifstream base(pchMessage); while (getline(base, line)) ++countLine; Student *student = new Student[countLine]; int i = 0; while (base) { base >> student[i].id >> student[i].name >> student[i].surname >> student[i].rating; i++; } base.close(); in my file:
111 aaa aaa 90 222 bbb bbb 72 Reads from file:
-842150451 -6.27744e+66 -842150451 -6.27744e+66 What am I doing wrong?