Solved

How do I append output?

Posted on 2011-03-08
3
368 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 31

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

776 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