How do you read from a binary file into a structure that contains multiple vectors?
For example
struct studentRecords
{
string user;
vector<string> friends;
vector<string> enemies;
}
From what i gather if i wanted to output that data structure into a binary file i would need to create my own write function that iterates through the variables in the data structure and also each vector element
Such as:
void writeToFile()
{
//create fstream etc.
myFile.write << user
for(int i=0; i< friends.size(); i++)
write << friends[i];
for(int i=0; i< friends.size(); i++)
write << enemies[i];
}
which seems fine but when i want to read the details of the binary files into a new data structure, how do it do this when vector1(friends) and vector2(enemies) might not be the same length?
How do i find the size of a vector stored into a binary file?
Thanks in advanced