HI!
I want to open a file and write some characters at the first of the file (or maybe after the 3rd character) and leaving the other characters in the file unchanged ;
This is what I did :
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
#include <fstream>
using std :: ios ;
int main ()
{
std :: fstream myfile ("test.txt" , ios :: out | ios :: app) ;
myfile.seekp (0) ;
myfile << "H" ;
}
I think the "seekp (0)" function doesn't work ;
Everything I do the program writes a "H" at the end of the file ;
Sorry for spamming!
But I really need an answer!
I want to know how can I write some characters at the beginning of a file without erasing/deleting the other characters
Whae I open file in ios::out mode , it deletes other characters in the file. and when I open it in ios::out and ios::app mode I can't write things at the first of the file , It always writes them at the end.
Thanks In Advance