• Advertisement

Archived

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

seeking a file using ifstream

This topic is 5900 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