Thread: About appending to a file

  1. #1
    Registered User
    Join Date
    Apr 2012
    Location
    Florida, Dade County, Homestrad, 33031
    Posts
    40

    About appending to a file

    Hi all
    I have a different problem now -- trying to use "ios::app".

    I understand it is what you use to append to a file, but where is it placed?

    in
    Code:
     ifstream a_file ios::app?
    in
    Code:
     ofstream b_file ios::app?
    in both?.... where?

  2. #2
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Appendig to a stream that you want to read doesn't make sense. does it ?

    Kurt

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    You use the open mode flags when you open the file, or with the non-empty constructor.
    Code:
    ofstream out1;
    out1.open("YourFileName", std::ios::app);
    ofstream out2("YourFileName", std::ios::app);

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File appending
    By rtram in forum C Programming
    Replies: 2
    Last Post: 12-04-2009, 01:06 PM
  2. Appending mid file
    By valaris in forum C Programming
    Replies: 4
    Last Post: 09-05-2008, 08:54 PM
  3. appending to a file
    By kippwinger in forum C++ Programming
    Replies: 9
    Last Post: 03-25-2004, 12:33 PM
  4. Appending to a File
    By mightymouse in forum C Programming
    Replies: 1
    Last Post: 03-15-2004, 05:00 PM