Here is a listing of C programming Objective Questions on “File Access” along with answers, explanations and/or solutions:
1. What are the first and second arguments of fopen?
a) A character string containing the name of the file & the second argument is the mode
b) A character string containing the name of the user & the second argument is the mode
c) A character string containing file pointer & the second argument is the mode
d) None of the mentioned
Answer: a
Clarification: None.
2. For binary files, a ___ must be appended to the mode string.
a) Nothing
b) “b”
c) “binary”
d) “01”
Answer: b
Clarification: None.
3. What will fopen will return, if there is any error while opening a file?
a) Nothing
b) EOF
c) NULL
d) Depends on compiler
Answer: c
Clarification: None.
4. What is the return value of getc()?
a) The next character from the stream is not referred by file pointer
b) EOF for end of file or error
c) Nothing
d) None of the mentioned
Answer: b
Clarification: None.
5. When a C program is started, O.S environment is responsible for opening file and providing pointer for that file?
a) Standard input
b) Standard output
c) Standard error
d) All of the mentioned
Answer: d
Clarification: None.
6. In C language, FILE is of which data type?
a) int
b) char *
c) struct
d) None of the mentioned
Answer: c
Clarification: None.
7. What is meant by ‘a’ in the following C operation?
fp = fopen("Random.txt", "a");
a) Attach
b) Append
c) Apprehend
d) Add
Answer: b
Clarification: None.
8. Which of the following mode argument is used to truncate?
a) a
b) f
c) w
d) t
Answer: c
Clarification: None.
9. Which type of files can’t be opened using fopen()?
a) .txt
b) .bin
c) .c
d) none of the mentioned
Answer: d
Clarification: None.
