How to append a character starting from the end of a file

Does anyone know if its possible to open a file for appending but then I need to be able to replace the last character written to the file with another. How can I advance the pointer going backwards towards the start of the file and write to each character that I would like to change ? I am also closing the file after each write or a single character then opening it with the append mode set.

Thanks

Victor

It would be good if you read the whole file in memory, change/replace whatever you want and than again write back to the file.
Opening the file for each character is going to be very slow operation.
The problem occurs if the whole file is very big like some server log files their filesize can reach a few Gbs.
memory mapped files can be used. the mmap() function. I think that would work.
Last edited on
Thanks for all the suggestions I will take a look at the available options. Appreciate the reply. Victor.
Topic archived. No new replies allowed.