How do I append output?

Posted on 2011-03-08
Last Modified: 2013-12-14
Please see the related my question is...instead of OVERWRITING the contents of the text file, I would like the output to APPEND to the existing content.  How do I do this?
Question by:shaolinfunk
LVL 31

Accepted Solution

Zoppo earned 500 total points
ID: 35068322
Hi shaolinfunk,

it should be enough to open the 'ofstream' with and additional open mode parameter:

ofstream os("c:\\debug.txt", ios_base::out | ios_base::app );

Open in new window

Hope that helps,


Author Closing Comment

ID: 35068335
Thank you ZOPPO, works perfectly!

Expert Comment

ID: 35068528
CFile myFile("c:\\Test.txt", CFile::modeNoTruncate | CFile::modeCreate | CFile::modeReadWrite );

  CString str("This is a test");
  myFile.Write(str, str.GetLength() );

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
eclipse luna javeEE perspecive missing 5 97
Copying WordPress Pages 5 76
I could not build boost code, 10 78
C++ mouse_event mouse look 7 70
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now