Deck 10: Data Files

Full screen (f)
exit full mode
Question
In the context of data processing, a C program is not usually considered data, and the term file, or data file, is typically used to refer only to external files that contain the data used in a C program.
Use Space or
up arrow
down arrow
to flip the card.
Question
The internal name is the name of a file as it is known by the operating system.
Question
A manageable length for a filename is 24 to 30 characters, with an outside maximum of 511 characters.
Question
Most C compilers require a program file to have either the extension c or cc.
Question
The advantage of binary files is typically speed and compactness.
Question
It typically takes less space to store most numbers using their binary code than as individual character values.
Question
A file stream that receives data from a file into a program is referred to as an input file stream.
Question
FILE fp; correctly declares a file stream.
Question
Opening a file stream establishes the physical communication link between the program and the data file.
Question
The file open function is called open().
Question
Permissible file opening modes are r, w, or p, which represent reading, writing, or appending to a file.
Question
The only difference between a file opened in w mode and one opened in w+ mode is where the data is physically placed in the file.
Question
If a file opened for reading does not exist, the fopen() function returns the NULL address value.
Question
The exit() function is a systems call that passes its integer argument directly to the operating system and then terminates program operation.
Question
It is important to check the return value when making an fopen() call because the call is really a request to the operating system to open a file.
Question
The fflush() function breaks the link between the file's external and internal names, releasing the internal file pointer name, which can then be used for another file.
Question
The maximum number of files that can be opened at one time is defined by the system symbolic constant FOPEN_MAX.
Question
The end-of-file sentinel is never counted as part of the file.
Question
The functions fgetc() and fgets() return the named constant EOF when the marker is detected.
Question
A logical file pointer is one that references a file of related data that has been saved under a common name; that is, it "points to" a data file.
Question
A physical file pointer "points to" a hardware device, such as a keyboard, screen, or printer.
Question
stdin and stderr frequently refer to the same device.
Question
Most IBM or IBM-compatible personal computers assign the name prn to the printer connected to the computer.
Question
The standard library functions rewind(), fseek(), and ftell() can be used to provide random access to a file.
Question
The function prototype for ftell() is contained in stdlib.h.
Question
Binary files frequently require less storage space than their character-based counterparts.
Question
Data that is stored together under a common name on a storage medium other than the computer's main memory is called a ____.

A)database
B)data file
C)text file
D)binary file
Question
The maximum allowable filename in the DOS operating system is ____.

A)8 characters plus an optional period and 3-character extension
B)14 characters
C)155 characters
D)255 characters
Question
The maximum allowable filename in current Unix versions is ____.

A)8 characters plus an optional period and 3-character extension
B)14 characters
C)155 characters
D)255 characters
Question
The maximum allowable filename in the Windows 98, 2000 and XP operating system families is ____.

A)8 characters plus an optional period and 3-character extension
B)14 characters
C)155 characters
D)255 characters
Question
____ files store each individual character, such as a letter, digit, dollar sign, decimal point, and so on, using an individual character code.

A)Data
B)Text
C)Binary
D)ASCII
Question
The standard input stream is named ____.

A)stdin
B)stdout
C)instream
D)ostream
Question
The standard output stream is named ____.

A)stdin
B)stdout
C)instream
D)ostream
Question
Naming a file stream is accomplished by declaring a variable name to be of type ____.

A)FSTREAM
B)fstream
C)FILE
D)file
Question
Notice that each file stream name, when it is declared, is preceded by a(n) ____.

A)pipe
B)underscore
C)ampersand
D)asterisk
Question
The actual declaration of the FILE structure is contained in the ____ standard header file.

A)stdio.h
B)stdlib.h
C)file.h
D)stream.h
Question
____ creates a new file and makes the file available for output; if a file exists with the same name, the old file is erased.

A)fileOut = fopen("prices.dat","r");
B)fileOut = fopen("prices.dat","w");
C)fileOut = fopen("prices.dat","a");
D)fileOut = fopen("prices.dat","b");
Question
____ makes an existing file available for data to be added to the end of the file; if the file opened does not exist, a new file with the designated name is created and made available to receive output from the program.

A)fileOut = fopen("prices.dat","r");
B)fileOut = fopen("prices.dat","w");
C)fileOut = fopen("prices.dat","a");
D)fileOut = fopen("prices.dat","b");
Question
A file stream is closed using the ____ function.

A)exit()
B)osclose()
C)fclose()
D)close()
Question
____ writes a string to a file.

A)fputc()
B)fputs()
C)fwrites()
D)fprintf()
Question
C appends the low-value hexadecimal byte ____ as the end-of-file (EOF) sentinel when a file is closed.

A)0x00
B)0x01
C)0x99
D)0xFF
Question
____ reads values for the listed arguments from the file, according to the format.

A)fgetc()
B)fgets()
C)fprintf()
D)fscanf()
Question
The function fgets() returns ____ when it detects the end of a file.

A)0x00
B)'\N'
C)'\n'
D)'\0'
Question
The ____ function call requires three arguments: an address where the first character read will be stored, the maximum number of characters to be read, and the name of the input file.

A)fgetc()
B)fgets()
C)fprintf()
D)fscanf()
Question
____ causes the same display as the statement printf("Hello World!");.

A)fprintf(stdout,"Hello World!");
B)fprintf(stdin,"Hello World!");
C)fprintf(stderr,"Hello World!");
D)fprintf(NULL,"Hello World!");
Question
fputc() is the general form of ____.

A)fput()
B)putc()
C)putchar()
D)fputchar()
Question
The statement ____ causes the string Hello World! to be printed directly at the printer.

A)fprintf(lprn,"Hello World!");
B)fprintf("lprn","Hello World!");
C)fprintf(prn,"Hello World!");
D)fprintf("prn","Hello World!");
Question
When working with random access files, the ____ function resets the current position to the start of the file.

A)rewind()
B)reset()
C)fseek()
D)flush()
Question
When working with random access files, the ____ function returns the offset value of the next character that will be read or written.

A) rewind()
C) fseek()
B) ftell()
D) flush()
Question
To write to a binary file you use the ____ function.

A) fput()
C) fwrite()
B) fputb()
D) write()
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 10: Data Files
1
In the context of data processing, a C program is not usually considered data, and the term file, or data file, is typically used to refer only to external files that contain the data used in a C program.
True
2
The internal name is the name of a file as it is known by the operating system.
False
3
A manageable length for a filename is 24 to 30 characters, with an outside maximum of 511 characters.
False
4
Most C compilers require a program file to have either the extension c or cc.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
The advantage of binary files is typically speed and compactness.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
It typically takes less space to store most numbers using their binary code than as individual character values.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
A file stream that receives data from a file into a program is referred to as an input file stream.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
FILE fp; correctly declares a file stream.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
Opening a file stream establishes the physical communication link between the program and the data file.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
The file open function is called open().
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
Permissible file opening modes are r, w, or p, which represent reading, writing, or appending to a file.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
The only difference between a file opened in w mode and one opened in w+ mode is where the data is physically placed in the file.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
If a file opened for reading does not exist, the fopen() function returns the NULL address value.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
The exit() function is a systems call that passes its integer argument directly to the operating system and then terminates program operation.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
It is important to check the return value when making an fopen() call because the call is really a request to the operating system to open a file.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
The fflush() function breaks the link between the file's external and internal names, releasing the internal file pointer name, which can then be used for another file.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
The maximum number of files that can be opened at one time is defined by the system symbolic constant FOPEN_MAX.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
The end-of-file sentinel is never counted as part of the file.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
The functions fgetc() and fgets() return the named constant EOF when the marker is detected.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
A logical file pointer is one that references a file of related data that has been saved under a common name; that is, it "points to" a data file.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
A physical file pointer "points to" a hardware device, such as a keyboard, screen, or printer.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
stdin and stderr frequently refer to the same device.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
Most IBM or IBM-compatible personal computers assign the name prn to the printer connected to the computer.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
The standard library functions rewind(), fseek(), and ftell() can be used to provide random access to a file.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
The function prototype for ftell() is contained in stdlib.h.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
Binary files frequently require less storage space than their character-based counterparts.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
Data that is stored together under a common name on a storage medium other than the computer's main memory is called a ____.

A)database
B)data file
C)text file
D)binary file
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
The maximum allowable filename in the DOS operating system is ____.

A)8 characters plus an optional period and 3-character extension
B)14 characters
C)155 characters
D)255 characters
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
The maximum allowable filename in current Unix versions is ____.

A)8 characters plus an optional period and 3-character extension
B)14 characters
C)155 characters
D)255 characters
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
The maximum allowable filename in the Windows 98, 2000 and XP operating system families is ____.

A)8 characters plus an optional period and 3-character extension
B)14 characters
C)155 characters
D)255 characters
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
____ files store each individual character, such as a letter, digit, dollar sign, decimal point, and so on, using an individual character code.

A)Data
B)Text
C)Binary
D)ASCII
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
The standard input stream is named ____.

A)stdin
B)stdout
C)instream
D)ostream
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
The standard output stream is named ____.

A)stdin
B)stdout
C)instream
D)ostream
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
Naming a file stream is accomplished by declaring a variable name to be of type ____.

A)FSTREAM
B)fstream
C)FILE
D)file
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
Notice that each file stream name, when it is declared, is preceded by a(n) ____.

A)pipe
B)underscore
C)ampersand
D)asterisk
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
The actual declaration of the FILE structure is contained in the ____ standard header file.

A)stdio.h
B)stdlib.h
C)file.h
D)stream.h
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
____ creates a new file and makes the file available for output; if a file exists with the same name, the old file is erased.

A)fileOut = fopen("prices.dat","r");
B)fileOut = fopen("prices.dat","w");
C)fileOut = fopen("prices.dat","a");
D)fileOut = fopen("prices.dat","b");
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
____ makes an existing file available for data to be added to the end of the file; if the file opened does not exist, a new file with the designated name is created and made available to receive output from the program.

A)fileOut = fopen("prices.dat","r");
B)fileOut = fopen("prices.dat","w");
C)fileOut = fopen("prices.dat","a");
D)fileOut = fopen("prices.dat","b");
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
A file stream is closed using the ____ function.

A)exit()
B)osclose()
C)fclose()
D)close()
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
____ writes a string to a file.

A)fputc()
B)fputs()
C)fwrites()
D)fprintf()
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
C appends the low-value hexadecimal byte ____ as the end-of-file (EOF) sentinel when a file is closed.

A)0x00
B)0x01
C)0x99
D)0xFF
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
____ reads values for the listed arguments from the file, according to the format.

A)fgetc()
B)fgets()
C)fprintf()
D)fscanf()
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
The function fgets() returns ____ when it detects the end of a file.

A)0x00
B)'\N'
C)'\n'
D)'\0'
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
The ____ function call requires three arguments: an address where the first character read will be stored, the maximum number of characters to be read, and the name of the input file.

A)fgetc()
B)fgets()
C)fprintf()
D)fscanf()
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
____ causes the same display as the statement printf("Hello World!");.

A)fprintf(stdout,"Hello World!");
B)fprintf(stdin,"Hello World!");
C)fprintf(stderr,"Hello World!");
D)fprintf(NULL,"Hello World!");
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
fputc() is the general form of ____.

A)fput()
B)putc()
C)putchar()
D)fputchar()
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
The statement ____ causes the string Hello World! to be printed directly at the printer.

A)fprintf(lprn,"Hello World!");
B)fprintf("lprn","Hello World!");
C)fprintf(prn,"Hello World!");
D)fprintf("prn","Hello World!");
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
When working with random access files, the ____ function resets the current position to the start of the file.

A)rewind()
B)reset()
C)fseek()
D)flush()
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
When working with random access files, the ____ function returns the offset value of the next character that will be read or written.

A) rewind()
C) fseek()
B) ftell()
D) flush()
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
To write to a binary file you use the ____ function.

A) fput()
C) fwrite()
B) fputb()
D) write()
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 50 flashcards in this deck.