Archived

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

randomDecay

seeking a file using ifstream

Recommended Posts

randomDecay    122
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
Bezzant    122
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