Code: Select all
void Load(const char* filename) {
std::ifstream in(filename, std::ios::binary);
in.read(reinterpret_cast<char*>(&curNumberEntries), sizeof(curNumberEntries));
for (int i = 0; i < curNumberEntries; i++) {
entries[i].Deserialize(in);
}
}
void Save(const char* filename)const {
std::ofstream out(filename, std::ios::binary);
out.write(reinterpret_cast<const char*> (&curNumberEntries), sizeof(curNumberEntries));
for (int i = 0; i < curNumberEntries; i++) {
entries[i].Serialize(out);
}
1. My understanding is that .write writes a chunk of data into the file starting at the address of curNumberentries with the size of curNumberEntries. Is this correct?
2. When you call .write/read does it move a pointer by the amount specified in sizeof?
3. Is this thing just writing a bunch of chars starting at the address specified into the file until it hits the limit specified by sizeof?
4. How are things organized in the file? Is it just one line of random data?
5. Why does this all seem like sorcery to me?