Searching a text file backwards
Hi all,
I thought this was an easy problem, but I haven't been able to find an answer in the last hour or so of searching, so maybe someone can direct me.
I have a text file that looks like this:
Code:
image 2318
281253 6.13325e+06 35.8228 0.0812
-3.13765 0.0117648 -1.07704
1150 1156 1164 1176 870 268 312 308 272 254 286 260 278 267 335 253 315...
725 741 749 757 761 787 803 967 975 971 971 979 1002 980 2086 2130 2168...
...
image 2319
283453 6.13525e+06 36.9328 0.0812
(repeating again)
I want to find the number after the word "image". In a previous post, I was helped to do this. However, I would like to know how to search backwards in the text file, because it grows to a few MB pretty quickly and the set of data I require will be either the last set of data or close to last set before the end of the text file.
I thought there was a flag or something I could go to such as eof() or something, but couldn't seem to find it (feof - C++ Reference doesn't seem to apply).
I can't find a .find backwards option either.
Perhaps I could read in the last section of code into a buffer big enough to hold a datalog, and then search that forwards? I don't really have much of an idea of how to do this though.
Thanks in advance for any suggestions, particularly with code, as I am out of my depth (but love a challenge).
Geek10