Tutorials - C++ Programming Quiz on C++ File I/O

Quiz: C File I/O

If you didn't feel like you nailed this quiz, try going back through Cprogramming.com's C File I/O tutorial. Otherwise, good job!

1. What object do you use to represent a file in C?
A. FILE*
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*



Quiz
Next lesson: Lesson 11, typecasting