Hello,
ostream - how to insert a line of text instead of overwrite in the beginning of the file?
#include <fstream.h>
int main()
{
char fileName[] = "SampleFile";
char buffer[255];
ofstream m_fp;
// m_fp.open(fileName, ofstream::ate );
m_fp.open(fileName, ios::in|ios::out);
m_fp.seekp(0, ios::beg );
m_fp << "This is the line written to the file 01"<<endl;
m_fp.close();
};
SampleFile has:
11111111111111111
2222222222222222
3333333333333333
44444444444444444
5555555555555555555555
When this progrom get executed, I got:
This is the line written to the file 01
33333333333
44444444444444444
5555555555555555555555
How can I get output like this?
This is the line written to the file 01
11111111111111111
2222222222222222
33333333333
44444444444444444
5555555555555555555555
Thanks,
Jeff