File Handling in C++

Last Updated :
Discuss
Comments

Question 1

Which header file is required to use file I/O operations?

  • <ifstream>

  • <ostream>

  • <fstream>

  • <iostream>

Question 2

Which among the following stream class is used to only write to files?

  • ofstream

  • ifstream

  • fstream

  • iostream

Question 3

Which stream class is used to only read from files?

  • ofstream

  • ifstream

  • fstream

  • iostream

Question 4

Which of the following is not used as a file opening mode?

  • ios::trunc

  • ios::binary

  • ios::in

  • ios::ate

Question 5

By default, all the files in C++ are opened in _________ mode.

  • Binary

  • Text

  • ISCII

  • VTC

Question 6

What is the use of ios::trunc mode?

  • To open a file in input mode

  • To open a file in output mode

  • To truncate an existing file to half

  • To truncate an existing file to zero

Question 7

Which among the follwoing function is used in C++ to get the current position of the file pointer in a file?

  • tell_p()

  • get_pos()

  • get_p()

  • tellg()

Question 8

Which function is used to reposition the file pointer?

  • moveg()

  • seekg()

  • changep()

  • go_p()

Question 9

Which of the following is used to move the file pointer to the start of a file?

  • ios::start

  • ios::cur

  • ios::first

  • ios::beg

Question 10

Which member function is used to determine whether the stream object is currently associated with a file?

  • is_open

  • buf

  • string

  • is_out

Tags:

There are 15 questions to complete.

Take a part in the ongoing discussion