Help needed about data input into a text file

I want to input data into text file while not deleting the original data in the file and I use something as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
	ofstream writefile;
	writefile.open("example1.txt");
        if (writefile.is_open())
        {
			for(j=0; j<N; j++)
			{
	        	writefile<<arrayQ[j][M-1];
	        	writefile<<" ";
        	}
            for(j=0; j<N; j++)
	        {
	    		writefile<<arrayP[j][M-1];
	    		writefile<<" ";
   	        }
            writefile.close();
	    }


But this will delete the original data. Anyone know how to solve this?
Open file in append mode ?
What do you mean by append mode? Can you give a sentence?
http://www.cplusplus.com/reference/fstream/ofstream/ofstream/
 
std::ofstream ofs ("test.txt", std::ofstream::out | std::ofstream::app);
Topic archived. No new replies allowed.