Hi,
I am using the STL and have a problem with the feature ifstream::seekg.
I want to read twice a file, the first read is ok, and after that I want to go back to the beginning of the file, in order to perform the second read.
Here is a code snippet:
#include <fstream>
#include <assert.h>
...
ifstream ins ("afile.txt"
;
assert (ins.is_open ());
while (not ins.eof ())
{
//read the file ...
}
ins.seekg (0, ios::beg);//go back to the beginning
assert (not ins.eof ());//fails
...
I don't clearly understand the first parameter of seekg, so I think I use it in a wrong way.
Can somebody tell me what is wrong?
Thanks
--
Globos
I am using the STL and have a problem with the feature ifstream::seekg.
I want to read twice a file, the first read is ok, and after that I want to go back to the beginning of the file, in order to perform the second read.
Here is a code snippet:
#include <fstream>
#include <assert.h>
...
ifstream ins ("afile.txt"
assert (ins.is_open ());
while (not ins.eof ())
{
//read the file ...
}
ins.seekg (0, ios::beg);//go back to the beginning
assert (not ins.eof ());//fails
...
I don't clearly understand the first parameter of seekg, so I think I use it in a wrong way.
Can somebody tell me what is wrong?
Thanks
--
Globos