hi I am trying to write into a file which already has something in it.
like for example i have
x
y
z
in the file and if i want to put k after x,y and z like
x
y
z
k.
my code goes this way
int main () {
//string line;
ofstream myfile;
int i=0;
myfile.open ("example2.txt");
myfile.seekp (0, ios::end);
while(myfile.eof()){
}
myfile << "Writing this to a file.\n";
myfile.close();
return 0;
}
everytime i am compiling this program its creating a new example2 text file, but i want the output to be added to the existing lines in the text file.could anyone tell how i can do it..