Does closing a stream also reset the position of the stream in the file?

Jul 14, 2017 at 8:08pm
Hello,

I would like to know if closing a stream also results in the resetting of the position of the stream in the particular file. In other words, if I close a stream, will the member function "seekg()", after reopening the stream, reset at the beginning of the file, or will it maintain its previous position?

Thank you!
Jul 14, 2017 at 8:24pm
It will reset.

If you want to save the position, store in a variable by calling tellg on the stream (before you close the stream).

Then when you reopen, you can seekg to that position you saved

See:
http://www.cplusplus.com/reference/istream/basic_istream/tellg/
http://www.cplusplus.com/reference/istream/basic_istream/seekg/
http://www.cplusplus.com/reference/fstream/basic_fstream/close/
Jul 14, 2017 at 8:58pm
Okay, thank you!
Topic archived. No new replies allowed.