Click here to Skip to main content
15,886,766 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.
I have function and i do not know what events are occurred in it. And I used it in many of the main, If i write a file by "ostream" , events are wrote successfully but when the function recalled, the events are cleaned from the text file and it start's to write from the first of the file!!
So, How can i write as appendix in a file ( such as text files ) for continuation?
How do I append to an existing text file?
Posted
Updated 18-Jun-12 16:27pm
v3
Comments
[no name] 18-Jun-12 20:49pm    
The word you are looking for is "append"
smss IR 18-Jun-12 20:53pm    
continuation -> append???
[no name] 18-Jun-12 20:55pm    
Yes. You want to append to your log file or whatever it is. Append means to add onto.
smss IR 18-Jun-12 20:58pm    
in which sentence?
[no name] 18-Jun-12 21:05pm    
What do you mean in which sentence? You whole question is about appending to a file not what you call "continuation".

Use seekp to set the pointer to the end of the file.

For details read this: ostream::seekp[^]
 
Share this answer
 
I suggest you use fstream instead. It will allow you to specify the mode in which the fie is opened - so you can specify whether to append or truncate an existing file.

See here: http://www.cplusplus.com/reference/iostream/fstream/open/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900