   Binary File IO
  Hi peopleim wanting to make a High score board for my game.The data i need to store for each player is put into a struct.struct PlayerInfo{string name;int score;int wordsTaken;float time; // in secondslist<string>words;}if im right, the list is a container, their for its size would vary.here is what i have got.PlayerInfo player;// player info stuff here like what words are added to the list etc.ofstream File("MyFile.dat", ios::binary);File.write((char *)(&player), sizeof(player));i understand why this wont work (i think), i think its because the list is a container, and varys in size according to what its storage type is, and how many elements are in it.because the list can vary in size, the sizeof(player) wont work because it needs a constant size, which is calculated by adding up the size in bytes of all the types in the struct, if you know what i mean. i think this is right, but im assuming a lot here, so please correct me if im wrong.so how do i get past this, how do i store all the words in the list, the players name, time and score, so that i can load the file back into another instance of PlayerInfo?My next question:once the above is sorted out, ill want to save more instances of player info, but i want to append them onto the end of the file, i think thats easy.but how do i load each instance of the playerInfo from the data file just saved? my theory is create a vector which can hold playerInfo, and push each instance onto the end of the vector.so i would use the following code:PlayerInfo player;vector<PlayerInfo>players;ifstream File("MyFile.dat", ios::binary);File.read((char *)(&player), sizeof(player)); // there is the sizeof thing againplayers.push_back(player);so that would be loading the first section of data into the first element of the vector, how do i load the second section of data, and save it into the second element of the vector, of course saving is easy. ( players.push_back(player); )one more question, why do we cast the types we are about to save to a char*?if you need more info, don't hesitate to ask.if you havent already noticed, im new to file input and output, your help would be greatly appreciated.   
  Check out this thread.   