C PROGRAM QUESTIONS : PART 26
If we have object from fstream class, then what will be the default mode of
opening the file?
ios::in|ios::out
ios::in|ios::out|ios::trunc
ios::in|ios::trunc
Default mode depends on compiler
Default mode depends on compiler
SHOW ANSWER
Which out of the following is return type of is_open() function.
int
bool
float
char *
SHOW ANSWER
Which of the following is not used to seek a file pointer?
ios::cur
ios::set
ios::end
ios::beg
SHOW ANSWER
Which of the following options is in relevance to ios::trunc mode?
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
If the file is opened for output operations and it already existed, its
previous content is deleted and replaced by the new one.
SHOW ANSWER
Which of the following option shows correct syntax for opening a file ?
myfile:open ("example.bin", ios::out);
myfile.open ("example.bin", ios::out);
myfile::open ("example.bin", ios::out);
myfile.open ("example.bin", ios:out);
myfile.open ("example.bin", ios::out);
SHOW ANSWER
Which of the following is correct syntax for closing a file in c++ ?
myfile$close();
myfile@close();
myfile:close();
myfile.close();
SHOW ANSWER
Which of the given options tells about the use of eof( ) stream function ?
Returns true if a file open for reading has reached the next character.
Returns true if a file open for reading has reached the next word.
Returns true if a file open for reading has reached the end.
Returns true if a file open for reading has reached the middle.
Returns true if a file open for reading has reached the end.
SHOW ANSWER
Which of the following functions allow to change the location of the get and
put positions ?
gog() and gop()
seekg() and seekp()
SHOW ANSWER
which of the following is used for offset counted from the current position?
ios::curr
ios::cr
ios::cur
ios::current
SHOW ANSWER
Which of the following is used for positioning relative to the beginning of a
stream ?
ios::start
ios::beg
ios::begin
ios::beginning
SHOW ANSWER
Which of the 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
SHOW ANSWER
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);
fileObject.seekg(n, ios::end );
SHOW ANSWER
How to find the position at end of fileObject ?
fileObject.seekg( 0, ios::end );
fileObject.seekg( 0, ios::end );
fileObject.seekg( 0, ios::end );
fileObject.seekg( 0, ios::end );
fileObject.seekg( 0, ios::end );
SHOW ANSWER