Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

randomDecay

seeking a file using ifstream

This topic is 6073 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all. I know you can use fseek using FILE *file to seek to a certain spot in a file. But I am using ifstream infile( "file.txt") and am not using a FILE *file pointer which fseek requires. My question is thus: is there a way to seek to a certain spot in a file using ifstream? Thanks

Share this post


Link to post
Share on other sites
Advertisement
what you want is: seekg

so

filein.seekg(offset, position)

where position is either:

ios::beg //beggining of file
ios::cur //current pos
ios::end //end of file

works quite like fseek.

edit: look on msdn for more info. if you need it, if you understand fseek it will be no prob

Edited by - Bezzant on December 31, 2001 1:59:38 PM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!