Solved

How do I append output?

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

729 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