Thread: fstream.

  1. #1
    deletedforumuser
    Guest

    fstream.

    Hmm, im right now working with a server/client application.

    May i know which ios::... to use to actually make it save into the file and keep the old text in it too...

    Normally, when you write new text, it directly deletes the text that were in the files.

    Thank you.

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    ios::append.....

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    >>Normally, when you write new text, it directly deletes the text that were in the files.
    actually unless you specify "std::ios::trunc" then it deletes the file, and makes a new one.

  4. #4
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    I think this table is most helpful in telling the file modes exactly. It conpares c++ open modes with c open modes

    Code:
    Table 33: Open modes and their C stdio counterparts 
    Open Mode 	C stdio Equivalent 	Effect
    
    in - "r" Open text file for reading only 
    out|trunc or out - "w" Truncate to 0 length, if existent, or create text file for writing only
    out|app - "a" Append; open or create text file only for writing at end of file
    in|out - "r+" Open text file for update (reading and writing)
    in|out|trunc - "w+" Truncate to 0 length, if existent, or create text file for update
    in|out|app - "a+" - Append; open or create text file for update, writing at end of file
    http://stdcxx.apache.org/doc/stdlibug/30-3.html

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fstream. I/O
    By kevinawad in forum C++ Programming
    Replies: 2
    Last Post: 07-07-2008, 09:19 AM
  2. using fstream
    By swgh in forum C++ Programming
    Replies: 1
    Last Post: 02-11-2006, 04:53 AM
  3. ARGH! fstream errors
    By OttoDestruct in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2004, 10:37 PM
  4. Are fstream and ofstream incompatible?
    By johnnyd in forum C++ Programming
    Replies: 5
    Last Post: 03-19-2003, 12:21 PM
  5. Problems with fstreams.
    By mosdef in forum C++ Programming
    Replies: 7
    Last Post: 06-19-2002, 03:36 PM