C++ File Handling Questions Answers

  • 8. Which is correct syntax for, position n bytes back from end of fileObject ?

    1. fileObject.seekg(ios::end, n);
    2. fileObject.seekg(n, ios:end );
    3. fileObject.seekg(n, ios::end );
    4. fileObject.seekg(ios:end, n);
    Answer :

    Option C

  • 9. Calling the stream's member function sync() causes an immediate synchronization.

    1. True
    2. False
    Answer :

    Option A

  • 10. How to get position to the nth byte of fileObject ?

    1. fileObject.seekg( 'filename',n );
    2. fileObject.seekg( n, 'filename' );
    3. fileObject.seekg( n );
    4. fileObject.seekg( n, ios::app );
    Answer :

    Option C

  • 11. Which functions allow to change the location of the get and put positions ?

    1. sg() and sp()
    2. sekg() and sekp()
    3. gog() and gop()
    4. seekg() and seekp()
    Answer :

    Option D

  • 12. ios::trunc is used for ?

    1. If the file is opened for output operations and it already existed, no action is taken.
    2. If the file is opened for output operations and it already existed, its previous content is deleted and replaced by the new one.
    3. If the file is opened for output operations and it already existed, then a new copy is created.
    4. None of above
    Answer :

    Option B

  • 13. Which stream class is to only write on files ?

    1. ofstream
    2. ifstream
    3. fstream
    4. iostream
    Answer :

    Option A

  • 14. Which is among following is used to Open a file for output and move the read/write control to the end of the file ?

    1. ios::ate
    2. ios::at
    3. ios::ann
    4. ios::end
    Answer :

    Option A

Please Like Us

disawar satta king