Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

To clear the show plus sign flag but leave the rest of the flags alone, you use

ID: 3763113 • Letter: T

Question

To clear the show plus sign flag but leave the rest of the flags alone, you use the _____________ member function and argument.

a. setf(! ios::showpos);

b. setprecision(ios::showpos);

c. unsetf(ios::showpos);

d. setf(ios::showneg);

e. unsetf(! ios::showneg);

To determine whether a file was opened successfully, one can use the ___________ fstream member function

A file stream, fStr, is open and attached to physical file.txt. To reset this file stream so that the file can be read again starting at the first line requires

To open a file for read-write and random access requires

d. The stream to be connected to the physical file object with first argument a C-string containing the physical file name and a second argument, ios::in | ios::out that specifies that the i/o with the file should be for either reading or writing.

e. #include, using std::fstream; and using std::ios;

Which of the following positions the file pointer for a file that has been opened for reading and writing?

a. close( )

Explanation / Answer

The solution is below.

To clear the show plus sign flag but leave the rest of the flags alone, you use the _____________ member function and argument.
a. setf(! ios::showpos);
b. setprecision(ios::showpos);
c. unsetf(ios::showpos);
d. setf(ios::showneg);
e. unsetf(! ios::showneg);

Ans: b


To determine whether a file was opened successfully, one can use the ___________ fstream member function
    a. close( )
    b. overloaded operator <<( )
   c.open( )
    d. eof( )
    e. flush( )

Ans : c


A file stream, fStr, is open and attached to physical file.txt. To reset this file stream so that the file can be read again starting at the first line requires
    a. “File stream fStr, reset yourself to the start of the file.”
    b. Calling the reset() member function using fStr as the calling object but with no argument.
    c. With calling object fStr call close()then call open( ) with argument “fStr”.
    d. Only calling the member function open() using fStr as the calling object with the “file.txt” as argument.
    e. None of the above. You can’t reread lines of a file that have already been read.

Ans : c

To open a file for read-write and random access requires
a.   The usual definition of an ofstream or ifstream object.
b.   A call to open ofstream or ifstream object, but there must be a second argument to the open function.
c.   The stream to be defined using the class fstream. defined in the header file.
d. The stream to be connected to the physical file object with first argument a C-string containing the physical file name and a second argument, ios::in | ios::out that specifies that the i/o with the file should be for either reading or writing.
e. #include, using std::fstream; and using std::ios;

Ans;e


Which of the following positions the file pointer for a file that has been opened for reading and writing?
    a. Use the size() member function on the file stream to position the file pointer.
    b. Use the seekp(arg) fstream member function with the number of records (counting the first record as 0) as argument to position the file pointer.
    c.Use the seekp(arg) fstream member function with the number of bytes to the record in question (counting the first byte as 0) as argument to position the file pointer.
    d. Use the sizeof operator to determine the number of bytes in the file stream.

Ans: b

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote