seeking a file using ifstream
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
I am not sure but i think its something like
ifstream f;
...
...
f.seek(int something); // not sure ot this
ifstream f;
...
...
f.seek(int something); // not sure ot this
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement