Solved

How do I append output?

Posted on 2011-03-08
3
362 Views
Last Modified: 2013-12-14
Please see the related question...now 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?
0
Comment
Question by:shaolinfunk
3 Comments
 
LVL 30

Accepted Solution

by:
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,

ZOPPO
0
 
LVL 1

Author Closing Comment

by:shaolinfunk
ID: 35068335
Thank you ZOPPO, works perfectly!
0
 

Expert Comment

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

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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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 …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

762 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

19 Experts available now in Live!

Get 1:1 Help Now