I have a function that computes the result I need on the fly (end result being ~50MB text files containing only chars), but in reverse order.
To illustrate: My function will compute "5, 4, 3, 2, 1, ...", but I require "1, 2, 3, 4, 5" to be written to a file.
I would like to write this to an output file, on the fly, from end to start.
Currently I'm buffering, reversing, and writing to a file with std::ofstream::binary, but I need to cut down the associated time and more importantly space overhead.
What is the most efficient way to do this?
Thank you.
Edit: output size is known.