how to read from txt file to array & how to omit heading in the txt file and store it to array

**To store the details in the txt file i have attached i wrote this coding in it how can i store the information separetly for round 1, round 2.... **

void getDetail(p_info gamers[ ])        //Function to input competitor details
{
    string arr[player];
    ifstream file;
    file.open("pp.txt");

    if(!file.is_open())
    {
        cerr<<"Cannot open the file"<<endl;
    }
    else
    {

            string line;
        for (int i= 0; i<player; i++)
        {
            getline(file,arr[i]);
            stringstream val;
            val << arr[i];

            getline(val, line, ';');
            gamers[i].num = atoi(line.c_str());

            getline(val, line, ';');
            gamers[i].name = line;

            getline(val, line, ';');
            gamers[i].age = atoi(line.c_str());

            getline(val, line, ';');
            gamers[i].coins = atoi(line.c_str());

            getline(val, line, ';');
            gamers[i].score = atoi(line.c_str());

            getline(val, line, ';');
            gamers[i].distance = atoi(line.c_str());
        }
        file.close();

how can i store the information separetly for round 1, round 2....

You could just add a line at the start with the "Round " and the round number, before you write any other information.

This article has been dead for over six months. Start a new discussion instead.