Kinniken
Registered
Hi, I need to read a file twice in one of my algorithm. My code, simplified, looks like that:
Now, what I was expecting was for the first part to execute on the file (it does), and then for the second part to do the same, re-starting from the beginning. It does not, instead behaving as if the file was empty.
I also tried using .seekg() to manually move back the pointer, it failed as well. Of course, I can always declare a second stream, but it's stupid.
Anyone has any idea of what I am doing wrong?
TIA,
Kinniken
PHP:
ifstream ifile;
ifile.open(fname.c_str(), ios::in);
//lots of code reading data using .get()
ifile.close();
ifile.open(fname.c_str(), ios::in);
//an other batch of code using .get()
Now, what I was expecting was for the first part to execute on the file (it does), and then for the second part to do the same, re-starting from the beginning. It does not, instead behaving as if the file was empty.
I also tried using .seekg() to manually move back the pointer, it failed as well. Of course, I can always declare a second stream, but it's stupid.
Anyone has any idea of what I am doing wrong?
TIA,
Kinniken