Ios::trunc

This is a discussion on Ios::trunc within the C++ Programming forums, part of the General Programming Boards category; is it ok to use ios::trunc even if you don't know if the file exists? as I want to write ...

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

    Ios::trunc

    is it ok to use ios::trunc even if you don't know if the file exists? as I want to write to a new file or re-write an existing one. How would I go about this?

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    ios::trunc
    If the file opened for output operations already existed before, its previous content is deleted and replaced by the new one.
    Seems ok!
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

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