Exam 12: Streams and File IO

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Assume that your program opens a file stream,has a file connected,and writes to the file.What changes need to be made to make your program write to the screen? (There will be stuff you need to delete and stuff that you need to change. )

(Essay)
4.9/5
(32)

What output is produced by the following code,assuming these lines of code are embedded in a correct program? cout << "*" << setw(5)<< 123; cout.setf(ios::left); cout << "*" << setw(5)<< 123; cout.setf(ios::right); cout << "*" << setw(5)<< 123 << "*" << endl;

(Essay)
4.7/5
(43)

The flush member function copies the file buffer to the file on the file medium (disk,tape,etc).

(True/False)
4.8/5
(42)

You have to #include <iomanip> as well as #include <iostream> when you use a line of code such as cout << setw(8)<< 123456 << endl; but not have to #include <iomanip> when you do the exact equivalent thing in cout.width(8); cout << 123456 << endl; Why is this?

(Essay)
4.8/5
(29)

If the output is too wide for the width specified in a setw manipulator or a call to the width member function,then the output is lost.

(True/False)
4.8/5
(42)

What output will be produced when the following code is executed? (Assume these lines are embedded in complete,correct programs,with proper #include directives. ) cout << "*"; cout.width(5); cout << 123 << "*" << 123 << "*" << endl; cout << setw(5)<< 123 << "*" << 123 << "*" << endl;

(Essay)
4.8/5
(40)

An istream object is already an ifstream object with some extra,added features.

(True/False)
4.8/5
(25)

Write a program that prompts for an input file name,receives the input file name in a C-string.The program should check for errors opening a file.It is not necessary for the program to do anything other than open the file.

(Essay)
4.9/5
(42)

Write a loop that will read from the current position in a file up to the end of the current line,and send this output to the screen.You may assume that any variables you need are declared,including file variables,and that any needed files have been successfully opened.

(Essay)
4.8/5
(39)

There are three calls to member functions of ostream object cout that set the format of stream output so that the format of the output is in fixed point,a decimal point always shows,and there are two places of decimals after the decimal point.Give these statements along with the necessary #include and using statements.

(Essay)
4.7/5
(37)

cout has type ostream,i.e. ,is an output object.

(True/False)
4.7/5
(36)

When you call the setf function on an output stream,the effect is only until the next output.

(True/False)
4.9/5
(45)

Assume you have opened and connected stream variables fileIn and fileOut.Assume further that you have finished with the input and output files.Write the statements necessary to close these files.

(Essay)
4.8/5
(41)

You get the manipulators endl and member functions setf and precision with the iostream header,but you have to include the iomanip header to get the manipulators setw and setprecision..

(True/False)
4.9/5
(34)

When you write ifstream inStream; inStream.open("infile.dat"); the file,infile.dat must be located in the directory where the program is being run.

(True/False)
4.8/5
(38)

When you use the open member function to tie a file name to a file stream,the file name is called the external file name,and the program refers to the file by the stream name.

(True/False)
4.8/5
(41)

You are writing a program.Give the necessary statements to open a file and to confirm that the file has been successfully opened for writing.Important: Why bother to test?

(Essay)
5.0/5
(39)

Setting the width of output with the manipulator setw is different from setting the width with the width member function.

(True/False)
4.9/5
(35)

An output stream is a stream of data flowing from your program,to a file,a device of some sort such as the screen.

(True/False)
4.8/5
(42)

What output is produced by the following code,assuming these lines of code are embedded in a correct program? cout << "*" << setw(5)<< 123 << "*" << 123 << "*" << endl; cout.setf(ios::showpos); cout << "*" << setw(5)<< 123 << "*" << 123 << "*" << endl; cout.unsetf(ios::showpos): cout.setf(ios::left); cout << "*" << setw(5)<< 123 << "*" << setw(5)<< 123 << "*" << endl;

(Essay)
4.8/5
(32)
Showing 21 - 40 of 43
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)