TOPIC 14.1.1
Saving Scores to Disk


main ()
{
    ifstream infile;
    ofstream outfile;
    int count;
    unsigned long score[10], onescore;


/////load high scores, if not present set to 0/////

    infile.open("highscr.dat", ios::in);

    if(infile)
    {
        for(count = 0, count < 10, count++)
        {
            infile >> onescore;  
            score[count] = onescore;
        }

        infile.close();
    }

    else
    {
        for(count = 0, count < 10, count++)
            score[count] = 0;
    }


/////play game/////

/////save new high scores/////

    outfile.open("highscr.dat", ios::out);

    if(outfile)
    {
        for(count = 0, count < 10, count++)
        {
            outfile << score[count] << endl;
        }
        outfile.close();
    }

    return 0;
}