1/221
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
fopen
The function used to open a file and return a FILE pointer for that file is .
NULL
When a file fails to open, fopen returns or evaluates as .
e
The format specifier to display floating point numbers in scientific notation is the percent sign followed by the letter: .
f
The format specifier that always shows the decimal point to display floating point numbers is the percent sign followed by the letter: .
c-string, character
"\n" is a and '\n' is a .
%.3f
Write the format specifier used to change the number of decimal places displayed in a floating point number to 3 decimal places.
getc, fgetc, and getchar
Which functions read one character even if that character is a blank space?
g
The format specifier to display floating point numbers in the shortest notation is the percent sign followed by the letter: .
fclose
When you are finished using a file you should close the file using the function .
fgets
is the safe function used to get a restricted length c-string from a file or the keyboard.
NULL
The special character used to mark the end of a C- string is called the character.
character
All data is input and output as data.
EOF
scanf, fscanf, and sscanf return .
C. displays a + in front of positive numbers.
A. displays a + in front of all numbers.
B. can be used to find the absolute value of an integer.
C. displays a + in front of positive numbers.
D. all of the above
A. prompting the file to ask for data
Which of the following is not used when using files for input and output?
A. prompting the file to ask for data
B. closing the file
C. ensuring that the file opened
D. opening the file
E. A and C
Which of the following function declarations will correctly pass a FILE pointer to the function?
A. void display(FILE* out);
B. void display(out* FILE);
C. FILE* display(FILE* out);
D. void display(FILE out);
E. A and C
C. must know the kind of data in the file.
In order to read data from a file correctly you
A. do not need to know the kind of data in the file.
B. should prompt the user for the data you are looking for.
C. must know the kind of data in the file.
D. A and C
A. when opening the file
When is the external name of the file used in the program?
A. when opening the file
B. only when reading from the file
C. never
D. any time you read or write to the file
A. isdigit
Which function returns true if the character argument is a digit?
A. isdigit
B. isalpha
C. islower
D. isspace
A. 10
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?
A. 10
B. 1
C. 0
D. none of the above
A. one character value.
The fgetc function reads
A. one character value.
B. one double value.
C. one integer value.
D. one float value.
A. display an error message and take some suitable action such as exit.
If a file did not open correctly, you should
A. display an error message and take some suitable action such as exit.
B. continue on anyway.
C. exit the program immediately.
D. Display an error message and continue on.
A. if(inFile == NULL)
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?
A. if(inFile == NULL)
B. if(inFile != NULL)
C. if(fail(inFILE))
D. if(inFile is not open)
C. display the integer x in at least width characters.
The command fprintf(outFile, "%*d",width, x); is used to
A. Use an entire line to output x.
B. change the number of characters in the output.
C. display the integer x in at least width characters.
D. set the filename of outFile to width characters.
C. one character value.
The fputc function outputs
A. one float value.
B. one double value.
C. one character value.
D. one integer value.
C. char filename[21];
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?
A. char filename[20];
B. char filename;
C. char filename[21];
D. char filename(20);
B. fp = fopen("project.txt", "a");
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 .
A. fp = fopen("project.txt",APPEND);
B. fp = fopen("project.txt", "a");
C. append(fp, "project.txt");
D. *fp = fopen("project.txt", "a");
B. inFile = fopen(filename, "r");
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?