C How To Program 8th Edition By Deitel & deitel – Test Bank
11.1 ________ are used for permanent retention of large amounts of data.
11.2 Which of the following is false?
a) Storage of data in memory variables is temporary; all such data is lost when a program terminates.
b) Computers store files on primary storage devices, typically disk storage devices.
c) Files are used for permanent retention of data (typically large amounts of data).
d) Storage of data in memory arrays is temporary; all such data is lost when a program terminates.
11.2 Files and Streams
11.3 Which of the following is not a stream associated with C files?
11.4 Which of the following is not part of the FILE structure specified in <stdio.h>?
(a) file descriptor
(b) open file table
(c) read/write methods
(d) file control block
11.5 C views each file simply as a sequential stream of __________.
11.6 Which of the following is not automatically opened when a C program begins?
a) standard error
b) standard output
c) standard dialog
d) standard input
11.7 __________ provide communication channels between files and programs.
c) File descriptors
d) File control blocks (FCBs)
11.8 The standard __________ stream enables a program to read data from the keyboard.
11.9 Function __________ reads one character from a file.
11.10 Function fputs writes a __________ to a file.
d) standard output
11.3 Creating a Sequential-Access File
11.11 Which mode would you use if you wanted to open a file for both reading and writing?
(d) all of these
11.12 If an error occurs while opening a file in any mode, function fopen returns ________.
11.13 Which statement is true?
a) C imposes no structure on a file.
b) C imposes record structure on a file.
c) C imposes sequential access on a file.
d) C imposes hierarchical access on a file.
11.14 Which statement is false?
a) The programmer must provide any file structure to meet the requirements of each particular application.
b) A programmer can impose a record structure on a file.
c) Records must be written to a C file in order by record key.
d) The notion of a record of a file does not exist in C.
11.15 Which of the following statements is false?
a) The programmer must know the specifics of the FILE structure to use files.
b) The FILE structure for a file leads indirectly to the operating system’s file control block (FCB) for a file.
c) If a file does not exist and is opened for writing fopen creates the file.
d) A C program administers each file with a separate FILE structure.
11.16 Before a file can be accessed it must first be
11.17 If an existing file is opened for writing __________.
a) the contents of the file are preserved
b) the contents of the file are discarded and an error code is returned
c) the contents of the file are discarded without warning
d) the newly written data is appended to the end of the file
11.18 Function feof __________.
a) forces an end-of-file condition
b) determines whether the end-of-file indicator is set for a file
c) sets the end-of-file indicator for a file
d) flushes the contents of the file from the current position to the end
11.19 Which statement is true?
a) Function fprintf is equivalent to printf.
b) Function fprintf is equivalent to printf except that fprintf also receives as an argument a file pointer for the file to which the data will be written.
c) Function fprintf is equivalent to printf except that fprintf also receives as an argument a file control block for the file to which the data will be written.
d) Function fprintf is equivalent to printf except that fprintf also disables the file end-of-file indicator.