HI!
I want to change somethings in a file.
I can't just append to it, because I want to change somethings in the first and in the middle and in the last .
and I don't want rename the file, I mean the file's name should remain as it is .
for example there is a file :
(student.txt)
I want to change it to this :
(student.txt)
3
john
14523
joe
369589
jack
9546 |
As you see the upper number is changed , a new person with a new ID is added .
I want to do these things in the same file .
What I have in mind is to copy all lines in a vector of strings and then erase the file content and write the vector to the file .
But I'm looking for a better and faster algorithm , because the file may sometimes be more than 1000 lines .
And I don't want to create another file first , erase this and copy that into this file.
Thanks In advance!