?
Solved

How do I append output?

Posted on 2011-03-08
3
Medium Priority
?
382 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

764 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