For a project of mine, I am writing a save file reader.
In the latest build I am getting a runtime error Unhandled exception at 0x00075256 in Final Assessment.exe: 0xC0000005: Access violation writing location 0xCCCCCCCC.
How can I go on to identify and correct the source of this error?
I believe the error happens when I create the ifstream object saveFile(), but I have been unable to find the exact source.
bool Game::load(){
    string data[9];
    ifstream saveFile("save.dat");
    int x = 0;
    if (saveFile.is_open()){
        while (!saveFile.eof()){
            getline(saveFile,data[x]);
            x++;
        }
        saveFile.close();
        string savePlayerName = data[0];
        int saveBaseHealth = stringToInt(data[1]);
        int saveHealth = stringToInt(data[2]);
        int saveKilled = stringToInt(data[3]);
        int saveMoney = stringToInt(data[4]);
        string saveWeaponName = data[5];;
        int saveAttack = stringToInt(data[6]);
        string saveArmorName = data[7];
        int saveDefense = stringToInt(data[8]);
        mainPlayer.setName(savePlayerName);
        mainPlayer.setBaseHealth(saveBaseHealth);
        mainPlayer.setHealth(saveHealth);
        mainPlayer.setEnemiesKilled(saveKilled);
        mainPlayer.setMoney(saveMoney);
        mainWeapon.setName(saveWeaponName);
        mainWeapon.setAttackPower(saveAttack);
        mainArmor.setName(saveArmorName);
        mainArmor.setDefense(saveDefense);
        return true;
    }
    else
    {
        return false;
    }
}

 
     
    