for example you have a:
string test;

void ExampleWindow::on_clicked(){
                ofstream myfile;
                string test; ("/home/ws14/Desktop/trunk/minisip/minisip/share/test.txt");
     		mydialfile << test;

how can I just add or insert a value on the file(test.txt). not just overwrite the file(test.txt) when the function(on_clicked) is being called.
All I need is if the function(on_clicked) is being called. The value of test is must add/insert(not ovewrite it) on the file(test.txt).
please help me.... thank you!

The easiest way would be to use the ios::app flag, this will open the file in append mode if the file exists, if it can't find the file, a new one will be created.

ofstream myfile;"path\filename.ext", ios::app );

Cheers for now,

ofstream filestr;"path\test.ext", ios::app );

It took you an hour longer to come up with the same solution as above. Only without code-tags...

thanks for the help! I already know. But thanks to all hope to help me again.

This is my next question: how to get a document from root?
because I have this code: ("/home/ws14/Desktop/test.txt");

But I need to change the path home/ws14 if I change user. Thanks!

This question has already been answered. Start a new discussion instead.