davario wrote:
hi everyone, I'm doing a project and it requires comparing entries on a
file. (the entries are separated by \r). i need to compare the first to
the second, then to the third etc. the same thing needs to be done with
the second entry (compared to the third, fourth etc. i want to do it
strait from the file, since it is a large amount of data. how do i
"remember" the place i have last read on the file? or perhaps how can i
remember the locations of all entries?
thanks in advance!!!
tellg and seekg are the methods for manipulating the position of a file.
tellg tells you where you are in a file, and seekg moves the file to a
new place.
But really this sounds horrendous, if the amount of data is so big that
you can't load it into memory then this is going to take days to
execute. If the amount of data is small enough to load into memory you
should.
But the real problem is the algorithm. Suppose you have 10,000 data
items, then you are going to have to do 50,000,000 (approx) comparisons.
Suppose you have 100,000 data items then that rises to 5,000,000,000
(approx) comparisons.
Since I don't know what you are comparing and why it's hard to suggest
improvements but you might consider sorting the data before you start
doing comparisons.
john