Name: Anonymous 2006-06-10 21:03
I'm writing a program in C++ to read in .geo format binary 3d graphic files. I have a file spec that gives me plainly the struct of the various data blocks. As a result, I can do this:
tPolygonObject getObjectEntry (ifstream& geoFile, udword address)
{ tPolygonObject tmpobj;
geoFile.seekg(address);
geoFile.read((char*)&tmpobj, sizeObjectEntry);
return tmpobj; }
// function call
polyObject[i] = getObjectEntry(geoFile, memFinger);
Meaning, I can simply read a chunk and plunk it down into my struct variable, and all the data members will be what they're supposed to be without me worrying about them lining up.
The problem is, what if I alter the structs, by adding more member variables? If I put them at the end, will it fill up the original ones in the same way, and leave the new members empty? Or will it just FUBAR everything?
tPolygonObject getObjectEntry (ifstream& geoFile, udword address)
{ tPolygonObject tmpobj;
geoFile.seekg(address);
geoFile.read((char*)&tmpobj, sizeObjectEntry);
return tmpobj; }
// function call
polyObject[i] = getObjectEntry(geoFile, memFinger);
Meaning, I can simply read a chunk and plunk it down into my struct variable, and all the data members will be what they're supposed to be without me worrying about them lining up.
The problem is, what if I alter the structs, by adding more member variables? If I put them at the end, will it fill up the original ones in the same way, and leave the new members empty? Or will it just FUBAR everything?