Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with ifstream::seekg and tellg

Status
Not open for further replies.

liquidsix

Programmer
May 16, 2004
1
CA
I'm writing a program that requires multiple passes over a file. I've created a file input stream and when i need to save a spot i use
streampos seekPosition = fin.tellg();
This returns the proper seek position. later when i use
fin.seekg(seekPosition); it does not go back to the proper spot in the file, in fact it stays at its last spot or the one before it in the file. This is only a problem in Microsoft Visual C++, does anyone know a way around this in Visual C++ or why it only happens with MSVC++?
 
use seekp instead of seekg. seekg sets the read position and seekp sets the write position. The same thing with tellp/tellg.

Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top