C++ File Handling Questions Answers
-
8. Which is correct syntax for, position n bytes back from end of fileObject ?
- fileObject.seekg(ios::end, n);
- fileObject.seekg(n, ios:end );
- fileObject.seekg(n, ios::end );
- fileObject.seekg(ios:end, n);
Answer :
Option C
-
9. Calling the stream's member function sync() causes an immediate synchronization.
- True
- False
Answer :
Option A
-
10. How to get position to the nth byte of fileObject ?
- fileObject.seekg( 'filename',n );
- fileObject.seekg( n, 'filename' );
- fileObject.seekg( n );
- fileObject.seekg( n, ios::app );
Answer :
Option C
-
11. Which functions allow to change the location of the get and put positions ?
- sg() and sp()
- sekg() and sekp()
- gog() and gop()
- seekg() and seekp()
Answer :
Option D
-
12. ios::trunc is used for ?
- If the file is opened for output operations and it already existed, no action is taken.
- If the file is opened for output operations and it already existed, its previous content is deleted and replaced by the new one.
- If the file is opened for output operations and it already existed, then a new copy is created.
- None of above
Answer :
Option B
-
13. Which stream class is to only write on files ?
- ofstream
- ifstream
- fstream
- 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 ?
- ios::ate
- ios::at
- ios::ann
- ios::end
Answer :
Option A