How to replace the contents of a file string if there is an integer value in each line.

    1 answer 1

    1. It can be fully read into an array and already work with the elements of the array, then overwrite this file by putting the elements of the array into it.

    2. Open the file for reading and writing (append), find and change the data in the desired line.

    • Only when you update (not overwrite) a file you must ensure that the lengths of the lines do not change. - avp