Hi all,
I have a file on c:\ and wish to write to the beginning of it, but not overwrite any of the content that is already there. Basically the contents of the file looks like this
This is line 2
This is line 3
This is line 4
This is line 5
I wish to open this file and write "This is line 1" at the beginning of it so it looks (suprisingly) like this
This is line 1
This is line 2
This is line 3
This is line 4
This is line 5
This is my code so far
But this still writes to the end of the file.Code:ofstream out("c:/myfile.txt", ios::app); out.seekp(0, ios::beg); out<<"This is line 1\r\n"; out.close();
Any ideas?
Thanks