please help me on this...:(

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Apr 2009
Posts: 50
Reputation: valtikz is on a distinguished road 
Solved Threads: 7
valtikz's Avatar
valtikz valtikz is offline Offline
Junior Poster in Training

please help me on this...:(

 
0
  #1
Apr 23rd, 2009
for example you have a:
string test;
  1.  
  2. void ExampleWindow::on_clicked(){
  3. ofstream myfile;
  4. string test;
  5. myfile.open ("/home/ws14/Desktop/trunk/minisip/minisip/share/test.txt");
  6. mydialfile << test;
  7. mydialfile.close();
  8. }

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!
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: please help me on this...:(

 
0
  #2
Apr 23rd, 2009
  1. myfile.open(filename,ios::app);
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 339
Reputation: JasonHippy is just really nice JasonHippy is just really nice JasonHippy is just really nice JasonHippy is just really nice 
Solved Threads: 61
JasonHippy's Avatar
JasonHippy JasonHippy is offline Offline
Posting Whiz

Re: please help me on this...:(

 
0
  #3
Apr 23rd, 2009
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.

  1. ofstream myfile;
  2. myfile.open("path\filename.ext", ios::app );

Cheers for now,
Jas.
If you're into metal, check out my new band at:
http://www.myspace.com/kinasis
Now booking gigs for 2010....
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 37
Reputation: shefeekj has a little shameless behaviour in the past 
Solved Threads: 2
shefeekj shefeekj is offline Offline
Light Poster

Re: please help me on this...:(

 
-1
  #4
Apr 23rd, 2009
ofstream filestr;

filestr.open("path\test.ext", ios::app );
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 50
Reputation: valtikz is on a distinguished road 
Solved Threads: 7
valtikz's Avatar
valtikz valtikz is offline Offline
Junior Poster in Training

Re: please help me on this...:(

 
0
  #5
Apr 23rd, 2009
thanks for the help! I already know. But thanks to all hope to help me again.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 50
Reputation: valtikz is on a distinguished road 
Solved Threads: 7
valtikz's Avatar
valtikz valtikz is offline Offline
Junior Poster in Training

Re: please help me on this...:(

 
0
  #6
Apr 23rd, 2009
This is my next question: how to get a document from root?
because I have this code:
  1. myfile.open ("/home/ws14/Desktop/test.txt");

But I need to change the path home/ws14 if I change user. Thanks!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC