-1

whenever I run the program in the second run, it keeps running in the while loop I don't know why. the file is storing an array of a struct.

int readFile(int num, string fName, player players[]){
ifstream oFile;
oFile.open(fName.c_str(), ios::in);
if(oFile.is_open()){
    
    while(!oFile.eof()){

        getline(oFile, players[num].name);
        oFile>>players[num].id;
        oFile>>players[num].age;
        oFile>>players[num].gender;
        num++;
    }
    num--;
}
else
cout<<"dosent open";
oFile.close();
return num;
}
Hassan
  • 1
  • 1
  • Please edit the question and place code in `code` blocks, your `}` is currently outside the blocks. It needs community edit or your edit. – Sunderam Dubey May 07 '22 at 18:55

0 Answers0