I ran into an problem while working on my school assignment. I have an input file from which I should construct objects of a structure.
int student_count = 0;
struct Student {
  string name;
  string surname;
  int ID;
  vector<int> grade;
} students[50];
int main() {
  ifstream inp;
  inp.open("PODACI.txt");
  while (!inp.eof()) {
    static int i = 0;
    inp >> students[i].name >> students[i].surname >> students[i].ID;
    student_count++;
    i++;
  }
  for (int i = 0; i < student_count; i++) {
    cout << students[i].name << students[i].surname << students[i].ID;
  }
}
This is what I have done so far. It takes in the first line as the name, second line as the ID, and the third line is an comma-separated array of numbers in the file, I want to take that as an input and store as an vector of the struct.
##Look of input file.txt
John Doe
1542
5,6,4,7,10
Note: There are multiple students in the input file, first three lines of file is first student, next three lines second student and so on...
 
    