How to store an array in a file?
Okay, I have a game with a structure that holds all the player information. I've figured out how to save and load the basic variable types, but I've run into trouble with an array I've added to the player structure. Here's the code I use to save:
And the code for loading is of course pretty much the same. The variable I need to store is called Player.m_iaPlayer_Inventory
CFile file(_T(m_sPlayer_Name), CFile::modeCreate|CFile::modeWrite);
CArchive ar(&file , CArchive::store);
ar << m_sPlayer_Name << Player.m_iHealth << Player.m_iHealth_Max << Player.m_iGold << Player.m_iExperience
<< Player.m_iPlayer_Level << Player.m_iStrength << Player.m_iDefense << Player.m_sWeapon_Name << Player.m_iWeapon_Damage
<< Player.m_sArmor_Name << Player.m_iArmor_Damage << Player.m_iWeapon_Damage_Roll << Player.m_bPlayer_Can_Camp