1/66
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
The function used to open a file and return a FILE pointer for that file is
fopen()
When a file fails to open, fopen returns or evaluates as
NULL
The format specifier to display floating point numbers in scientific notation is the percent sign followed by the letter:
%e
The format specifier used to change the number of decimal places displayed in a floating point numbers is the percent sign followed by the letter:
%.nf
“/n” is a _____ and ‘/n’ is a _____
Escape sequence, character
Write the format specifier used to change the number of decimal placed displayed in a floating point number to 3 decimal places
%.3f
Which functions read one character even if that character is a blank space
getchar()
The format specifier to display floating point numbers in the shortest notation is the percent sign followed by the letter:
%g
When you are finished using a file you should close the file using the function
fclose()
_______ is the safe function used to get a restricted length c-string from a file or the keyboard
fgets()
The special character used to mark the end of a C-string is called the ____ character
null
All data is input and output as ______ data
character
scanf, fscanf and sscanf return
Number of successfully assigned inputs (EOF)
+ is a format specifier flag that
Displays a + infront of positive numbers
Which of the following is not used when using files for input and output?
Prompting the file to ask for data
Which of the following function declarations will correctly pass a FILE pointer to the function?
void display (FILE* out)
In order to read data from a file correctly you
Must know the kind of data in the file
When is the external name of the file used in the program?
When opening the file
Which function returns true if the character argument is a digit?
isdigit
If the user types in the characters ‘1’ and ‘0’ and your program reads them into an integer variable with no spaces in between using scanf and %d, what is the value stored into that integer?
10
The function fgetc function reads
One character value
If a file did not open correctly, you should
Display an error message and take some suitable action such as exit
Which of the following is the correct way to determine if a file referred to in the FILE pointer named inFile failed to open correctly after calling fopen?
if (inFIle==NULL)
The command fprintf(outFile, “%*d”, width, x); is used to
Display the integer x in at least width characters
The fputc function outputs
One character value
To open a file with a user supplied name, you would need to store the name in a variable. If the file name was to have no more than 20 characters in it, which would be an appropriate declaration of the file name variable?
char filename[21]
To open an output file and add to the end of the data already in the file using the FILE pointer fp you would write ______
fp=fopen(“project.txt”, “a”);
If the name of the input file was in a c-string variable named filename, which of the following is the correct way to open the file for reading and associate it with the FILE object referred to by the FILE pointer named inFile?
inFile=fopen(filename, “r”)
We have a file that has a name in it, but the name is written one character per line. We need to write this name to the screen without the newlines. What is wrong with the following code?
Our output has new lines in it.
Which include directive is necessary for file IO?
#include <stdio.h>
A ______ is a variable that has unknown structure and is only modified through a pointer variable called a handle through function calls
Opaque object
Which statement correctly opens a file named project.txt for reading and holds the address of the FILE object in a variable named in_file
in_file=fopen(“project.txt”, “r”);
What is wrong with the following code?
int test=1;
while(test!=EOF){
test=fscan(fileIn, "%d", value);
fprintf(fileout, "The next value ism%d\n", value);
}
a) we have read past the end of the input file and output one garbage value
b) we have nothing written past the end of the output file
c) nothing
d) a and b
We have read past the end of the input file and output one garbage value
The function isalpha (arg) returns
Returns true if arg is an alphabetical character
The command fprintf(outfile, “%.2f”, x)
Outputs the floating point value x sent to outFIle with 2 decimal places changing the value of x
After a file is opened, before the FILE pointer is used for input and output, it should be
Checked to see if it is opened correctly
The command fprint(outFile, “%5d”, x) is used to
Display the integer x in at least 5 characters
What is the output of the following code?
char ch= ‘G’;
printf(“%d\n”, tolower(ch));
The integer value of ‘g’
Which of the following is the correct way to close a file referred to by the FILE pointer variable named outFile?
fclose(outFile)
Which of the following loop condition statements will read all the data in the file assuming that each record in the file is two integer values, and you will read the first one into a variable named intOne, and the other into intTwo?
while(fscanf(inFile, “%d%d”, &intOne, &intTwo)==2)
THe formatting options that were discussed for printf do not work for fprintf
False
‘\n’ is two characters
False
FOPEN_MAX is a macro defined in stdlib.h
False
You may have as many files open as you would like
False
The fgets function will stop reading in characters if it encounters any whitespace character or the end of file and makes sure that you cannot read more characters than indicated by the max parameter
False
You may not have more than file open at any one time
False
The function gets is designed to read a c-string from standard input but is considered unsafe and should not be used because you do not list the buffer size in the argument list
True
Since the type FILE is an opaque object type and we only interact with it through pointers and functions, we should never dereference a FILE pointer
True
FILE pointers may be passed to a function
True
You must use a field width specifier in each format specifier that you want output in a certain field
False