PDA

View Full Version : Start writing from a specific line in a file



nackasha
17th August 2011, 16:45
Hello Folks,

I have some data that i saved to file.txt. The data looks like:

abc
def
ghi
123
456
678
.
.
.

I have no commas in the file, and each column has only one value.

What i want to do is to start writing from a specific line. For example, start writing from the 3rd line and change the content to the 9th line.

How can i do that please ?

Thank you in advance,

mvuori
17th August 2011, 17:31
The easiest way is to do it is in memory. Read the file into a QStringList, change the lines (now QStrings) and write the whole thing back to the file.