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

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!
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/
Okay, thank you!
Topic archived. No new replies allowed.