Thread: Wrting to the END of a text file

  1. #1
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052

    Wrting to the END of a text file

    How do you make it so you write to the end of a file, instead of writing over the file?

  2. #2
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    anybody...?

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    23
    I suggest you show us a piece of you code that wirtes over the file, and we'll correct it to appending to the file...

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    72
    Hi,
    when you use

    Code:
    void open(const char *s,
        ios_base::openmode mode = ios_base::out | ios_base::trunc);
    check the predefined constants in ios_base class:

    Code:
        static const openmode app, ate, binary, in, out, trunc;
    and provide ios_base :: app instead of ios_base::trunc

    e.g.

    Code:
         output.open("data.txt", ios_base::out | ios_base::app);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 04:27 PM
  2. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  3. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  4. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  5. Ok, Structs, I need help I am not familiar with them
    By incognito in forum C++ Programming
    Replies: 7
    Last Post: 06-29-2002, 09:45 PM