C File Management-1
1. Which of the following true about FILE *fp
a) FILE is a keyword in C for representing files and fp is a variable of FILE type
b) FILE is a stream
c) FILE is a buffered stream
d) FILE is a structure and fp is a pointer to the structure of FILE type
Answer: D
fp is a pointer of FILE type and FILE is a structure that store following
information about opened file.
2. Which of the following mode argument is used to truncate?
a) a
b) w
c) f
d) t
Answer: B
No explanation is given for this question.
3. 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 pointer & the second argument is the mode
d) None of the mentioned
Answer: A
No explanation is given for this question.
4. FILE is of type ______
a) int type
b) char * type
c) struct type
d) None of the mentioned
Answer: A
It is what is typically termed an opaque data type, meaning it's typically declared as a
simple structure, and then internally in the OS libraries the FILE pointer is cast to
the actual date-type of the data-structure that the OS will use access data from a file.
A lot of these details are system-specific though, so depending on the OS, the
definition may differ.
5. A data of the file is stored in _______
a) Ram
b) Hard disk
c) Rom
d) None
Answer: B
No explanation is given for this question.
6. fseek() should be preferred over rewind() mainly because
a) rewind() doesn't work for empty files
b) rewind() may fail for large files
c) In rewind, there is no way to check if the operations completed successfully
d) All of the above
Answer: C
The rewind function sets the file position indicator for the stream pointed
to by stream to the beginning of the file.
7. FILE reserved word is _______
a) A structure tag declared in stdio.h
b) One of the basic datatypes in c
c) Pointer to the structure defined in stdio.h
d) It is a type name defined in stdio.h
Answer: D
It is a type name defined in stdio.h.
8. For binary files, a ___ must be appended to the mode string.
a) "b"
b) "B"
c) "binary"
d) "01"
Answer: A
No explanation is given for this question.
9. What is the function of the mode ‘ w+’?
a) create text file for writing, discard previous contents if any
b) create text file for update, discard previous contents if any
c) create text file for writing, do not discard previous contents if any
d) create text file for update, do not discard previous contents if any
Answer: B
w+ is a mode used to open a text file for update (i. e., writing and reading), discard previous contents if any.
10. Which of the following statements about stdout and stderr are true?
a) Same
b) Both connected to screen always
c) Both connected to screen by default
d) stdout is line buffered but stderr is unbuffered
Answer: C
No explanation is given for this question.