Can I change a file stream object's read position in C++? I mean I have a file with a series of integers separated by a newline character. Can I read the first five integers into some variables and then move the read position back to read the fifth integer one more time?
dmm
0
Newbie Poster
Recommended Answers
Jump to PostYou can move the position (using seekg) either by an offset, or to a previous point (that was saved by tellg). Unless your file is very strictly formatted, you probably want the latter. So in your case, call tellg to get the file position before reading the fifth line, then …
All 3 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.