Hello I have a question about looping and reading files using fstream. I have this code and the problem is I can't get it to loop.
int studentSize, mark1,mark2,mark3; 
string programme, course1, course2, course3;
filein >> studentSize;
filein >> programme;
filein.ignore();
while(getline(filein, name, '\n') &&
      filein >> id &&
      filein >> ws && 
      getline(filein, course1, '\n') &&
      filein >> mark1 &&
      filein >> ws &&
      getline(filein, course2, '\n') &&
      filein >> mark2 &&
      filein >> ws &&
      getline(filein, course3, '\n') &&
      filein >> mark3 &&
      filein >> ws)
{
    if( programme == "Physics" )
    {
        for(int i=0; i < studentSize; i++)
        {
            phys.push_back(new physics());
            phys[i]->setNameId(name, id);
            phys[i]->addCourse(course1, mark1);
            phys[i]->addCourse(course2, mark2);
            phys[i]->addCourse(course3, mark3);
            sRecord[id] = phys[i];
        }
    }
}
I tried to add a while loop before the code. And do something like this:
filein >> studentSize;
filein >> programme;
filein >> repeat;
filein.ignore();
while(repeat == '&')
  { //above code }
and make my file like this so that it loops when fstream >> detects the & character but it doesn't work. I have no idea why.
2
Mathematics
&
Ashley    
7961000
Doto
99
C++
99
Meh
99
&
Dwayne
7961222
Quantum
99
heh*
99
Computing
99
 
    