I'm trying to read from Scores.txt into my Player
vector. using the following code.
std::ifstream fin;
std::string alo;
int al;
Player* p = new Player;
std::vector<Player*> mPlayer;
fin.open("Scores.txt");
while (fin.good()) {
fin >> alo >> al;
p->setName(alo);
p->setScore(al);
mPlayer.push_back(p);
}
my text file is as follows:
Ali 25
Reza 101
Igor 18
Katie 20
Jacky 18
macky 20
however, after outputting myPlayer
vector I get the following result:
macky 20
macky 20
macky 20
macky 20
macky 20
macky 20