The ____________ fstream member function closes a file stream. Explain why it is best to close a file when the program is through processing the data in the file.

a. close( )
b. overloaded operator <<( )
c. open( )
d. eof( )
e. flush( )


a)
Explanation: Part a) close() is used without argument to close the file to prevent file corruption, a possibility if the program terminates abnormally. Part b) has nothing to do with opening a file. Part c) opens a file stream and connects it to a physical file. The argument is a C-string constant or variable. Part d) returns a type bool value of true if the file pointer has attempted to read at end of file. (To read beyond end of file is an error.) Part e) flush( ) is used without argument to write the file buffer out to the physical medium.

Computer Science & Information Technology

You might also like to view...

Given the code:

``` int number, *ptr_num = &number;``` what is wrong with the assignment: ptr_num = 3 ? A. You can’t assign an int to a pointer. B. ptr_num is not defined. C. The number variable must be assigned an address. D. Nothing is wrong.

Computer Science & Information Technology

Which site has easy-to-read overviews of a lot of technical information?

A) Washington Post Learning Network B) Beginner's Guide to Life and the Internet C) Wikipedia D) Webopedia

Computer Science & Information Technology

What are the scenarios that can result from using SMTP protocol for delivering e-mail messages?

What will be an ideal response?

Computer Science & Information Technology

What utility should always be used in order to delete checkpoints?

A. Command prompt B. Windows Explorer C. Hyper-V Manager D. PowerShell

Computer Science & Information Technology