enter between lines in file

closed account (1vf9z8AR)
Like i enter in file like this

suyash
singh
hello

and then i can enter between like this

suyash
newline
singh
16

I dont even know how to begin with :(
Easiest way is to read file line-by-line into a container such as a vector. Make whatever changes you want to the vector. Then save the contents of the vector back to the file.

There are other ways, such as reading from one file and writing to a different file, with no need for a vector. Than at the end, delete the original file and rename the new file to give it the old name.
closed account (1vf9z8AR)
how do i do your second method?
i know how to rename and delete files.And also how to write read search and delete words from file.
Basically read one line at a time. Examine its contents and decide whether it is of any interest to you. If not, simply write it to the file.

You would need to figure out the logic, depending on what action you want to carry out.


Topic archived. No new replies allowed.