Default mode of opening file is ios::out|ios::trunk - File Handling

Q.  If we have object from ofstream class, then default mode of opening the file is _____ .
- Published on 17 Jul 15

a. ios::in
b. ios::out
c. ios::in|ios::trunc
d. ios::out|ios::trunk

ANSWER: ios::out|ios::trunk
 

    Discussion

  • NIGAM   -Posted on 05 Apr 19
    best of luck
  • Raj   -Posted on 06 Oct 15
    If we have object from ofstream class, then default mode of opening the file is
    ios::out|ios::trunk. If you have not provides the mode with ofstream then it will automatically consider this mode.
    Class --------------- Default mode
    • ofstream        ios::out|ios::trunk
    • ifstream      ios::in
    • fstream      ios::in|ios::out

Post your comment / Share knowledge


Enter the code shown above:
 
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)