C MCQs: File Access- Part 1

Here is a listing of C programming interview questions on “File Access” along with answers, explanations and/or solutions:

1. The first and second arguments of fopen are
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 poniter & the second argument is the mode.
d) None of the mentioned of the mentioned

2. For binary files, a ___ must be appended to the mode string.
a) Nothing
b) “b”
c) “binary”
d) “01”

3. If there is any error while opening a file, fopen will return

a) Nothing
b) EOF
c) NULL
d) Depends on compiler

4. Which is true about getc.getc returns?

a) The next character from the stream referred to by file pointer
b) EOF for end of file or error
c) Both a & b
d) Nothing.

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 menitoned

6. FILE is of type ______ ?
a) int type
b) char * type
c) struct type
d) None of the mentioned

7. What is the meant by ‘a’ in the following operation?
fp = fopen(“Random.txt”, “a”);
a) Attach
b) Append
c) Apprehend
d) Add

8. Which of the following mode argument is used to truncate?
a) a
b) f
c) w
d) t

9. Which type of files can’t be opened using fopen()?
a) .txt
b) .bin
c) .c
d) None of the mentioned

 

Next –> C MCQs: File Access- Part 2

Leave a Comment