How to change the file indicator position in cpp?

Status
Not open for further replies.

42ndEngineer

Newbie level 2
Joined
May 24, 2020
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
12
I tried using seekg but it didnt work. Im trying to read a specific line(like 3rd line) by getline function. When i use seekg i cant even read from the start(i tried seekg(0)). It would be great if anyone can help.
 

I haven't used seekg, but how would you use it to read a specific line?
It seems that seekg doesn't know anything about lines.

I think you should use getline repeatedly until you reach the wanted line, and just ignore the lines before it.
 

I did what you said but i was looking or an efficient way because if i move indicator where i want it would improve my code so much.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…