but how to use pointer to move the reading postion? point to what?
Imagine file access is like an old fashioned mono-directional cassette tape player (ie, no rewinding!) - the only way to find the position of a chunk of data is to play through the tape from the start, and read each chunk of data sequentially.
The chunk of data you read is always at the "head" position - The tape moves forward, rather than the head (and since you can't rewind, the data which has already passed the head is gone from the stream). You can choose to either store the data at the head or discard it. The tape rolls on once the head has read whatever's at that position. Whatever you do, you *must* read it in order to move the tape on.
here's a quick example of reading the 3rd word in a stringstream (Which is just another 'flavour' of streams -
fstreams work in exactly the same way)
#include <iostream>
#include <sstream>
int main()
{
std::stringstream ss("the quick brown fox jumped over the lazy dog");
std::string str;
const int position(3);
for(int i(0); i!=position; ++i)
ss >> str;
std::cout << str;
}
This example outputs the word "brown" - the first 2 words, "the" and "quick" were also read, but discarded, since the only word I was interested in was the 3rd one.