seeking a file using ifstream

Started by
2 comments, last by randomDecay 22 years, 3 months ago
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
Advertisement
I am not sure but i think its something like

ifstream f;
...
...
f.seek(int something); // not sure ot this

Hello from my world
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
seekg is the method you''re looking for.

This topic is closed to new replies.

Advertisement