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!
QuizNext lesson: Lesson 11, typecasting
1. What object do you use to represent a file in C?
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?
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*