Reverse the order of lines in a text file while preserving the contents of each line
Not going to bother testing with the task recommended file. It demonstrates nothing to do with file handling, record separators, memory conservation or anything useful. May as well just be "Reverse this list" for all the good it does.
Lots of assumptions
Simplest thing that could possibly satisfy the extremely vague task description and completely glossing over all of the questions raised on the discussion page.
ASSUMPTIONS:
Few assumptions
Processes a small (configurable) number of bytes at a time so file can be multi-terabyte and it will handle with ease. Does assume Latin 1 for reduced complexity.
No assumptions were made concerning line/record termination, full stop.
Run the following to generate nul.txt. (digits 1 through 6 repeated 8 times with double null as record separators):
Output:
Last updated