I have class player that contains some attributes. I m filling a file with player's data but i want to assign a new id number every time the function is called in a way that the new player's id will be increased every time. So i made this while loop to read number of players and update the player's new id but this doesn't work and nothing is written in the file.
void Player::create_player()
{
    fstream file;
        Player plyr; string passwordt;
        int aget = 0;
        long int id_nmbert = 0;
        string emailt, ingame_namet, full_namet,yes;
        file.open("player_database.dat", ios::binary | ios::app);
        if (!file.is_open())
            throw exception();
        while (file >> yes)  ///
            id_nmbert++;     ///
        cout << "insert player's full name" << endl;
        cin >> full_namet;
        plyr.full_name = full_namet;
        cout << "insert player's age" << endl;
        cin >> aget;
        plyr.age = aget;
        cout << "insert player's email" << endl;
        cin >> emailt;
        plyr.email = emailt;
        cout << "insert player's password" << endl;
        cin >> password;
        plyr.password = passwordt;
        cout << "insert player's ingame name" << endl;
        cin >> ingame_namet;
        plyr.ingame_name = ingame_namet;
        plyr.id_nmber = id_nmbert;
        file.write((char*)&plyr, sizeof(Player));
        file.close();
}
Tried This but it's even worse.
while (!file.eof())
id_numbert;
There are similar questions but not in c++ :).
 
     
     
    