Hi everyone,
I'm looking for a way to reset the read / write pointers of an fstream (ios::in|ios::base|ios::binary) to 0 without the use of seekp(0)/ seekg(0).
(This is a small part of an assignment I have not been able to solve or find any clue on how to attack this problem. The rest is already solved.)
Below is the code I'm using right now ( with(!) seekp()|seekg()) to test the rest of the program.
If anyone could give me a clue, hint, solution or whatever on how to solve that problem, I'd really appreciate it.
Thanks for your help in advance.
I'm looking for a way to reset the read / write pointers of an fstream (ios::in|ios::base|ios::binary) to 0 without the use of seekp(0)/ seekg(0).
(This is a small part of an assignment I have not been able to solve or find any clue on how to attack this problem. The rest is already solved.)
Below is the code I'm using right now ( with(!) seekp()|seekg()) to test the rest of the program.
Code:
void File::moveTo(uint pos)
{
if (!_file.is_open())
{
cout << "problem with file \n";
}
_actpos = _file.tellg();
if ((pos*_recSize) < _actpos)
{
_file.seekp(0);
_file.seekg(0);
//cout << "Reset: " << _actpos << " --|--";
}
_actpos = _file.tellg();
while((pos*_recSize) != _actpos)
{
_file.read(_recBuffer, _recSize);
_actpos = _file.tellg();
}
}
If anyone could give me a clue, hint, solution or whatever on how to solve that problem, I'd really appreciate it.
Thanks for your help in advance.