Text into TextFiles

Okay,I want to do is add a string into an existing text file.This existing text file has a paragraph, what I want to do is add the string the user types
and without tempering with the already existing text file, simply slip in that particular string.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
  ofstream myfile;
  myfile.open ("Text.txt");
  myfile << "Random sentence.\n";
  myfile.close();
    
    
    system("pause");
    return 0;
}


when this program is run, the string "Random sentence" appears but the existing paragraph disappears, I want to keep both.....thanks
Responded to this thread:
http://www.cplusplus.com/forum/beginner/109357/

Please only create one thread. For future reference, you can edit your own posts.
Topic archived. No new replies allowed.