(Note: sizeof(character) == 68 bytes)
I am having issues with fstream::seekg()/seekp(). It seems like when one is invoked to modify the get or put pointer, the other pointer follows it instead of staying in place. Example:
charfile.seekp(0,ios::beg);
cout << endl << "Put pointer is at " << charfile.tellp() << " bytes.";
charfile.seekg(0,ios::beg);
cout << endl << "Get pointer is at " << charfile.tellg() << " bytes.";
cout << endl << "Initializing slots..." << endl;
for(int i=0;i<CHARSLOTS;i++)
{
charfile.read((char*)(charbuf),sizeof(character));
cout << endl << "Get pointer is at " << charfile.tellg() << " bytes.";
cout << endl << "Put pointer is at " << charfile.tellp() << " bytes.";
Output of above code after 1 iteration of the for loop is:
Put pointer is at 0 bytes.
Get pointer is at 0 bytes.
Initializing slots...
Get pointer is at 68 bytes.
Put pointer is at 68 bytes.
As I understand it, fstream::read() advances the get pointer by however many bytes it read. In this case, it also advances the put pointer by an equivalent amount. What gives?
I have another fstream issue, but one problem at a time.