C
C
CakeCPP2020-01-06 02:19:31
Lua
CakeCPP, 2020-01-06 02:19:31

How to edit a line by its index when reading a file line by line?

Question in titler. That is, I need, let's say, edit the 22nd line of the file (Add a word to the end of the line)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dollar, 2020-01-06
@CakeCPP

1) Read all lines of the file into an array (table).
2) Change element (line) No. 22 in the array.
3) Overwrite the file by writing all lines from the array again.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question