Posted on 2002-03-22
what is the fastest way to read through a file. I will need to know things like...
what is the length (in LINES) of the file
I need to access the beggining of each line like a member of a list or array.
I was thinking of two or three things...
read the file a character at a time into a one char buffer, and then check the buffer for new lines, and increment a number at each time,
while reading into char a,
if a == std::endl
then I can seek with chars but I would probably have to makea list of all the positions of the \n
the downside to this is that it calls a loop for each character in the file.
I could also try to do it a line at a time, or, say 10 or 20 chars at a time...
what is the best way to do this w. the lest memory, processor.
I will need to completely reorder the list by the time I am done with it.