I just want to ask how to reach the position which I want
Just repeat the code Bench posted until you get to the desired line. You will have to use a loop and a counter integer to keep track of the line number that was just read. If you are confused about loops -- which is understandable -- you should read about them in your text book.
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)
std::stringstream ss("the quick brown fox jumped over the lazy dog");
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.
what is the type of "int position(3) ", different from "int a"
Yes, those are completely different! the line int position(3); does the same thing as int position = 3; In case you're wondering why I used the ( ) instead of assignment operator for built-in types is something of a style issue. Personally, I find it more idiomatic to initialise variables using the 'constructor' initialisation syntax rather than the assignment syntax. YMMV, sorry for the confusion :)