/* */ Click to Join Live Class with Shankar sir Call 9798158723

C File handling MCQ


Q1. Which of the following true about FILE *fp
  1. FILE is a keyword in C for representing files and fp is a variable of FILE type.
  2. FILE is a stream
  3. FILE is a buffered stream
  4. FILE is a structure and fp is a pointer to the structure of FILE type

Answer:- (D).
Explanations :fp is a pointer of FILE type and FILE is a structure that store following information about opened file.
Q2. Which of the following mode argument is used to truncate?
  1. a
  2. w
  3. f
  4. t

Answer:- (B).
Explanations :none.
Q3. The first and second arguments of fopen() are
  1. A character string containing the name of the file & the second argument is the mode
  2. A character string containing the name of the user & the second argument is the mode
  3. A character string containing file pointer & the second argument is the mode
  4. None of the mentioned

Answer:- (A).
Explanations :none.
Q4. FILE is of type ______
  1. int type
  2. char * type
  3. struct type
  4. None of the mentioned

Answer:- (C).
Explanations : 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.
Q5. fseek() should be preferred over rewind() mainly because
  1. rewind() doesn't work for empty files
  2. rewind() may fail for large files
  3. In rewind, there is no way to check if the operations completed successfully
  4. All of the above

Answer:- (C).
Explanations :The rewind function sets the file position indicator for the stream pointed to by stream to the beginning of the file.
Q6. FILE reserved word is?
  1. A structure tag declared in stdio.h
  2. One of the basic datatypes in c
  3. Pointer to the structure defined in stdio.h
  4. It is a type name defined in stdio.h

Answer:- (D).
Explanations :It is a type name defined in stdio.h
Q7. For binary files, a ___ must be appended to the mode string.
  1. "b"
  2. "B"
  3. binay"
  4. "01"

Answer:- (A).
Explanations :none.
Q8. Which of the following statements about stdout and stderr are true?
  1. Same
  2. Both connected to screen always.
  3. Both connected to screen by default.
  4. stdout is line buffered but stderr is unbuffered.

Answer:- (C).
Explanations :none
Q9. Which type of files can't be opened using fopen()?
  1. .txt
  2. .bin
  3. .c
  4. None of the above

Answer:- (D).
Explanations :none
Q10. When a C program is started, O.S environment is responsible for opening file and providing pointer for that file?
  1. Standard input
  2. Standard output
  3. Standard error
  4. All of the above

Answer:- (D).
Explanations :none