posted 12 years ago
For fun you might open a random access file and read characters from the last one backwards until you hit newline or start of file. It would be interesting to compare this to the 'read every line' alternative you mentioned for various file sizes. I suppose you could read more than one character at a time into a 'buffer' and search for the newline in the buffer. I'm not at all sure this would be worth doing.