hi
using C++ program how to insert a line containg "this is th inserted line" into a file using fstream???
for example let the file contin
--------------------------
line1
line2
line3
line4
-------------------------
I want to modify it to
---------------------------
line1
line2
This is the inserted line
line3
line4
----------------------------------
I will always insert a new line after lin2.
thanks in advance.
I'd read the file into a string, search for a newline, search for the next newline, insert the line into the string just after that second newline, delete the original contents of that file, and read into it. That's the easy way. http://cplusplus.com/reference/string/string/find/