Welcome to the C++ File Handling Quiz!. In this quiz each question is paired with a detailed explanation, ensuring you understand not only the correct answers but also the underlying concepts. From basic operations like reading and writing files to more complex tasks such as file manipulation and error handling, this quiz covers a comprehensive range of topics. Whether you’re just starting out or looking to deepen your expertise, this quiz will help you sharpen your skills in managing files effectively in C++.
Ready to test your knowledge? Let’s explore C++ file handling together!
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
There are 25 questions to complete.