Tutorials - C Programming Quiz on C File I/O

Quiz: C File I/O

If you're not sure you're ready to take a quiz on C File I/O, be sure to through Cprogramming.com's C File I/O tutorial. Otherwise, best of luck!

1. What object do you use to represent a file in C?
B. fopen
C. printf
D. fprintf

2. Before you can read or write to a file in C, what do you need to do?
A. Call fopen on the file
B. Create the file
C. Call fclose on the file
D. Use fprintf

3. How do you write a string of text into a file?
A. Open file and use fprintf.
B. Open a file and use printf, the output will go to the file instead of the screen.
C. Open a file, and use fputc repeatedly.
D. Use fread to read data into the file.

4. What flag do you need to pass to fopen to append to an existing file instead of recreating the file?
A. a
B. r
C. w
D. W+

5. How do you open a file for binary IO?
A. Use the "b" flag to fopen
B. Files are opened for binary IO by default
C. Use fread and fwrite
D. You need to use a special file type, BINARYFILE*

Answer Key
Next lesson: Lesson 11, typecasting