Possile add information to a test file instead of overwriting it?

This is a discussion on Possile add information to a test file instead of overwriting it? within the C Programming forums, part of the General Programming Boards category; I'm constantly calling a function which is writing to a text file, but each time I call the function, it ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    145

    Possile add information to a test file instead of overwriting it?

    I'm constantly calling a function which is writing to a text file, but each time I call the function, it overwrites the existing text file.

    Is there a way to add the text to the end of the text file instead of overwriting it each time?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Yes, open the file with the "a" mode for appending instead of "w" which truncates the file for overwriting.
    My best code is written with the delete key.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,533
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 08:35 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  5. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 09:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21